Skip to content

DateTimeInput inside Row causes layout error: ListTile receives unconstrained width #819

@ymmt2005

Description

@ymmt2005

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

  1. Create an A2UI surface with a Row containing a DateTimeInput:
    [
      {"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"}}}}
    ]
  2. Render with GenUiSurface
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1A high-priority issue. Someone should be assigned and actively working on it.front-line-handledCan wait until the second-line triage. The front-line triage already checked if it's a P0.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions