-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
P2An issue we'd like to fix eventually, but it's not being actively worked on.An issue we'd like to fix eventually, but it's not being actively worked on.a: core_catalogfront-line-handledCan wait until the second-line triage. The front-line triage already checked if it's a P0.Can wait until the second-line triage. The front-line triage already checked if it's a P0.
Description
Describe the bug
MultipleChoiceState.maxAllowedSelections casts _json['maxAllowedSelections'] directly to int?, but the JSON map stores numeric values as doubles. When the field is present you get type 'double' is not a subtype of type 'int?' in type cast. Code reference: packages/genui/lib/src/catalog/core_widgets/multiple_choice.dart:44-45.
To Reproduce
- Configure a multiple choice widget that sets
maxAllowedSelections(e.g. 3) and let it round-trip through the GenUI JSON map. - The JSON is decoded so numeric literals are
double(e.g.3.0). - When the getter runs, the cast to
int?throws and the widget fails to render.
Expected behavior
maxAllowedSelections should accept numeric JSON input and convert it to an int. Reading it as num? and calling .toInt() would avoid the crash.
Additional context
The same pattern might exist in other widget configs that assume JSON numbers deserialize as int. Fixing this getter would unblock multiple choice responses that limit the selection count.
Metadata
Metadata
Assignees
Labels
P2An issue we'd like to fix eventually, but it's not being actively worked on.An issue we'd like to fix eventually, but it's not being actively worked on.a: core_catalogfront-line-handledCan wait until the second-line triage. The front-line triage already checked if it's a P0.Can wait until the second-line triage. The front-line triage already checked if it's a P0.