Skip to content

fix(genui): show a literal CheckBox value - #1038

Open
diegolopezrm wants to merge 1 commit into
flutter:mainfrom
diegolopezrm:checkbox-literal-value
Open

diegolopezrm wants to merge 1 commit into
flutter:mainfrom
diegolopezrm:checkbox-literal-value

Conversation

@diegolopezrm

Copy link
Copy Markdown

Description

CheckBox.value is a booleanReference, so a literal, a {"path": ...} binding and a {"call": ...} are all valid. The widget bound the checkbox to a data model path and never read the literal, so a component that said the setting was on rendered unchecked, announced itself unchecked, and logged nothing to say the value had been dropped.

slider.dart and text_field.dart already fall back to the literal until the path holds something. This does the same, so the three inputs of the basic catalog treat their value the same way:

final bool? effectiveValue = value ?? (valueRef is bool ? valueRef : null);

Two tests: a literal value: true renders checked, and a {"path": ...} binding still starts unchecked and follows the data model once something writes to it.

Fixes a2ui-project/a2ui#2736.

Pre-launch Checklist

  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I read the Contributors Guide.
  • I have added sample code updates to the changelog.
  • I updated/added relevant documentation (doc comments with ///).
  • If my PR is a fork PR, I've checked that [e2e tests] passed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue where the CheckBox component failed to display its literal value when the bound data model path was not yet initialized. The implementation now falls back to the literal value (valueRef) if the path has not been written to, aligning its behavior with Slider and TextField. Additionally, corresponding widget tests have been added to verify this behavior, and the changelog has been updated. There are no review comments, and I have no feedback to provide.

@josemontespg

Copy link
Copy Markdown
Collaborator

Thanks, this is the fix suggested in a2ui-project/a2ui#2736 (Slider-style literal fallback plus tests). @gspencergoog, could you review? You have every commit on check_box.dart.

@gspencergoog

Copy link
Copy Markdown
Collaborator

The CI problems will get better once #1040 lands.

@diegolopezrm

diegolopezrm commented Sep 23, 2026 •

Copy link
Copy Markdown
Author

The eight red checks aren't from this change. The beta jobs die in pub get, before a single test runs:

So, because catalog_gallery depends on flutter_test from sdk, version solving failed.

The whole matrix goes down with it, json_schema_builder and the copyright job included, so it's beta 3.49.0-0.1.pre not resolving rather than anything in here. They were green on #1035 on the 18th, so it broke sometime this past week. Happy to file it separately if it isn't known yet.

`CheckBox.value` is a `booleanReference`: a literal, a `{"path": ...}`
binding and a `{"call": ...}` are all valid. The widget bound to a data
model path and never read the literal, so a component that said the
setting was on rendered unchecked and announced itself unchecked, with
nothing logged to say the value had been dropped.

`Slider` and `TextField` already fall back to the literal until the path
holds something. This does the same, so the three inputs of the basic
catalog now treat their value the same way.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: genui's CheckBox ignores a literal value and renders unchecked

3 participants