-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Use this system prompt (or any prompt that generates TextFields inside a Row/Column):
Your job is to build UI using ONLY the built-in CoreCatalogItems.
Always generate:
- A top search bar (TextField + Button)
- A search results list
- A chat message list
- A bottom input area (TextField + Button)
IMPORTANT:
- Wrap every TextField in a width-bounded Box or Expanded.
- Do NOT put TextField directly inside a Row or Column without constraints.
- Do not specify surface IDs manually.
- Always send BeginRendering after updates.
=====================================================================================
Actual Results :
Flutter throws the runtime error:
InputDecorator cannot have an unbounded width.
TextField must be inside a width-bounded parent.
The crash happens even when:
-
Instructions explicitly force width constraints
-
TextFields are wrapped in Containers, Boxes, or Expanded
-
No manual surface IDs are used
-
Using only default CoreCatalogItems
=====================================================================================
Expected Results :
GenUI should generate TextField layouts that obey Flutter’s width-bounded constraint:
-
TextField inside Box(width: infinity)
-
TextField inside Expanded
-
TextField inside Container (width constraints)
-
The UI should render without crashing.
=====================================================================================
Sample Code:
import 'package:flutter/material.dart';
import 'package:genui/genui.dart';
import 'package:genui_firebase_ai/genui_firebase_ai.dart';
class Home extends StatefulWidget {
@OverRide
State createState() => _HomeState();
}
class _HomeState extends State {
late GenUiConversation conversation;
final _surfaceIds = [];
@OverRide
void initState() {
super.initState();
final catalog = CoreCatalogItems.asCatalog();
final generator = FirebaseAiContentGenerator(
catalog: catalog,
systemInstruction: "<SYSTEM PROMPT FROM ABOVE>",
);
conversation = GenUiConversation(
genUiManager: GenUiManager(catalog: catalog),
contentGenerator: generator,
onSurfaceAdded: (s) => setState(() => _surfaceIds.add(s.surfaceId)),
onSurfaceDeleted: (s) => setState(() => _surfaceIds.remove(s.surfaceId)),
);
generator.a2uiMessageStream.listen((msg) {
conversation.genUiManager.handleMessage(msg);
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: _surfaceIds.map((id) {
return GenUiSurface(
host: conversation.host,
surfaceId: id,
);
}).toList(),
),
);
}
}