-
Notifications
You must be signed in to change notification settings - Fork 143
Description
Description
When a DateTimeInput component is placed as a direct child of a Row, it causes a Flutter layout error:
BoxConstraints forces an infinite width.
The offending constraints were: BoxConstraints(w=Infinity, 0.0<=h<=Infinity)
The DateTimeInput catalog item renders as a ListTile, which requires bounded width. Inside a Row, non-flex children receive unbounded main-axis constraints. Without a weight (which wraps the child in Flexible), ListTile cannot determine its width and crashes.
Root Cause
In lib/src/catalog/core_widgets/row.dart, the explicitListBuilder auto-assigns weight: 1 for TextField children:
weight:
getComponent(componentId)?.weight ??
(getComponent(componentId)?.type == 'TextField'
? 1
: null),This auto-detection does not cover DateTimeInput, even though it also renders as a widget (ListTile) that needs bounded width.
Steps to Reproduce
- Create an A2UI surface with a
Rowcontaining aDateTimeInput:[ {"id": "root", "component": {"Row": {"children": {"explicitList": ["text-input", "date-input", "button"]}}}}, {"id": "text-input", "component": {"TextField": {"text": {"path": "/text"}, "label": {"literalString": "Text"}}}}, {"id": "date-input", "component": {"DateTimeInput": {"value": {"path": "/date"}, "enableDate": true, "enableTime": false}}}, {"id": "button", "component": {"Button": {"child": "btn-text"}}}, {"id": "btn-text", "component": {"Text": {"text": {"literalString": "Go"}}}} ] - Render with
GenUiSurface - Observe layout crash
Workaround
Set "weight": 1 on the DateTimeInput component entry in the A2UI surface definition. The weight field is part of the A2UI spec (server_to_client.json) and causes genui to wrap the child in Flexible(flex: 1).
Suggested Fix
Add 'DateTimeInput' to the auto-weight check in row.dart (and the equivalent in templateListWidgetBuilder):
weight:
getComponent(componentId)?.weight ??
(getComponent(componentId)?.type == 'TextField' ||
getComponent(componentId)?.type == 'DateTimeInput'
? 1
: null),Environment
- genui: 0.7.0
- Flutter: 3.38.9