-
-
Notifications
You must be signed in to change notification settings - Fork 82
refactor: Simplify StacRadio and StacRadioGroup implementations #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Refactored StacRadioParser and StacRadioGroupParser to remove unnecessary dependencies and streamline widget structure. - Converted StacRadioWidget to a StatefulWidget for better state management. - Removed StacRadioGroupScope in favor of direct state management within StacRadioGroup. - Added new properties to StacRadio for enhanced customization: enabled, backgroundColor, side, and innerRadius. - Updated JSON serialization for new properties in StacRadio and StacRadioGroup.
WalkthroughConverted radio widgets to internal stateful management: removed the InheritedWidget radio scope, introduced a FocusNode-owning Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Parser as RadioGroupParser
participant Group as RadioGroup
participant RadioState as _RadioWidgetState
participant Model as StacRadio / StacRadioGroup
Parser->>RadioState: initialize _groupValue from model (initState)
RadioState->>RadioState: create FocusNode
Parser->>Group: build RadioGroup(groupValue: _groupValue, onChanged: _onChanged)
Group->>RadioState: user selects option -> onChanged(value)
RadioState->>RadioState: _onChanged updates _groupValue, writes formData if id
RadioState->>Model: invoke model.onChanged (if present)
RadioState->>RadioState: setState -> rebuild radios using widget.model and _focusNode
RadioState->>RadioState: dispose() -> dispose FocusNode
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart(2 hunks)packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart(2 hunks)packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_scope.dart(0 hunks)packages/stac_core/lib/widgets/radio/stac_radio.dart(2 hunks)packages/stac_core/lib/widgets/radio/stac_radio.g.dart(2 hunks)packages/stac_core/lib/widgets/radio_group/stac_radio_group.dart(3 hunks)packages/stac_core/lib/widgets/radio_group/stac_radio_group.g.dart(1 hunks)
💤 Files with no reviewable changes (1)
- packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_scope.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: pub_get_check
- GitHub Check: analyze
- GitHub Check: format
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart
Show resolved
Hide resolved
| Widget _buildCupertinoRadio(BuildContext context) { | ||
| return CupertinoRadio<dynamic>( | ||
| value: widget.model.value, | ||
| mouseCursor: widget.model.mouseCursor?.parse, | ||
| toggleable: widget.model.toggleable ?? false, | ||
| activeColor: widget.model.activeColor?.toColor(context), | ||
| inactiveColor: widget.model.inactiveColor?.toColor(context), | ||
| fillColor: widget.model.fillColor?.toColor(context), | ||
| focusColor: widget.model.focusColor?.toColor(context), | ||
| focusNode: _focusNode, | ||
| autofocus: widget.model.autofocus ?? false, | ||
| useCheckmarkStyle: widget.model.useCheckmarkStyle ?? false, | ||
| enabled: widget.model.enabled, | ||
| ); | ||
| } | ||
|
|
||
| Widget _buildAdaptiveRadio( | ||
| BuildContext context, | ||
| StacRadio model, | ||
| FocusNode focusNode, | ||
| ) { | ||
| return ValueListenableBuilder( | ||
| valueListenable: radioGroupScope!.radioGroupValue, | ||
| builder: (context, value, child) { | ||
| return Radio.adaptive( | ||
| value: model.value, | ||
| mouseCursor: model.mouseCursor?.parse, | ||
| toggleable: model.toggleable ?? false, | ||
| activeColor: model.activeColor?.toColor(context), | ||
| fillColor: WidgetStateProperty.all(model.fillColor?.toColor(context)), | ||
| focusColor: model.focusColor?.toColor(context), | ||
| hoverColor: model.hoverColor?.toColor(context), | ||
| overlayColor: WidgetStateProperty.all( | ||
| model.overlayColor?.toColor(context), | ||
| ), | ||
| splashRadius: model.splashRadius, | ||
| materialTapTargetSize: model.materialTapTargetSize?.parse, | ||
| visualDensity: model.visualDensity?.parse, | ||
| focusNode: focusNode, | ||
| autofocus: model.autofocus ?? false, | ||
| useCupertinoCheckmarkStyle: model.useCupertinoCheckmarkStyle ?? false, | ||
| ); | ||
| }, | ||
| Widget _buildAdaptiveRadio(BuildContext context) { | ||
| return Radio<dynamic>.adaptive( | ||
| value: widget.model.value, | ||
| mouseCursor: widget.model.mouseCursor?.parse, | ||
| toggleable: widget.model.toggleable ?? false, | ||
| activeColor: widget.model.activeColor?.toColor(context), | ||
| fillColor: WidgetStateProperty.all( | ||
| widget.model.fillColor?.toColor(context), | ||
| ), | ||
| focusColor: widget.model.focusColor?.toColor(context), | ||
| hoverColor: widget.model.hoverColor?.toColor(context), | ||
| overlayColor: WidgetStateProperty.all( | ||
| widget.model.overlayColor?.toColor(context), | ||
| ), | ||
| splashRadius: widget.model.splashRadius, | ||
| materialTapTargetSize: widget.model.materialTapTargetSize?.parse, | ||
| visualDensity: widget.model.visualDensity?.parse, | ||
| focusNode: _focusNode, | ||
| autofocus: widget.model.autofocus ?? false, | ||
| useCupertinoCheckmarkStyle: | ||
| widget.model.useCupertinoCheckmarkStyle ?? false, | ||
| enabled: widget.model.enabled, | ||
| backgroundColor: widget.model.backgroundColor != null | ||
| ? WidgetStateProperty.all( | ||
| widget.model.backgroundColor!.toColor(context), | ||
| ) | ||
| : null, | ||
| side: widget.model.side?.parse(context), | ||
| innerRadius: widget.model.innerRadius != null | ||
| ? WidgetStateProperty.all(widget.model.innerRadius) | ||
| : null, | ||
| ); | ||
| } | ||
|
|
||
| Widget _buildMaterialRadio( | ||
| BuildContext context, | ||
| StacRadio model, | ||
| FocusNode focusNode, | ||
| ) { | ||
| return ValueListenableBuilder( | ||
| valueListenable: radioGroupScope!.radioGroupValue, | ||
| builder: (context, value, child) { | ||
| return Radio( | ||
| value: model.value, | ||
| mouseCursor: model.mouseCursor?.parse, | ||
| toggleable: model.toggleable ?? false, | ||
| activeColor: model.activeColor?.toColor(context), | ||
| fillColor: WidgetStateProperty.all(model.fillColor?.toColor(context)), | ||
| focusColor: model.focusColor?.toColor(context), | ||
| hoverColor: model.hoverColor?.toColor(context), | ||
| overlayColor: WidgetStateProperty.all( | ||
| model.overlayColor?.toColor(context), | ||
| ), | ||
| splashRadius: model.splashRadius, | ||
| materialTapTargetSize: model.materialTapTargetSize?.parse, | ||
| visualDensity: model.visualDensity?.parse, | ||
| focusNode: focusNode, | ||
| autofocus: model.autofocus ?? false, | ||
| ); | ||
| }, | ||
| Widget _buildMaterialRadio(BuildContext context) { | ||
| return Radio<dynamic>( | ||
| value: widget.model.value, | ||
| mouseCursor: widget.model.mouseCursor?.parse, | ||
| toggleable: widget.model.toggleable ?? false, | ||
| activeColor: widget.model.activeColor?.toColor(context), | ||
| fillColor: WidgetStateProperty.all( | ||
| widget.model.fillColor?.toColor(context), | ||
| ), | ||
| focusColor: widget.model.focusColor?.toColor(context), | ||
| hoverColor: widget.model.hoverColor?.toColor(context), | ||
| overlayColor: WidgetStateProperty.all( | ||
| widget.model.overlayColor?.toColor(context), | ||
| ), | ||
| splashRadius: widget.model.splashRadius, | ||
| materialTapTargetSize: widget.model.materialTapTargetSize?.parse, | ||
| visualDensity: widget.model.visualDensity?.parse, | ||
| focusNode: _focusNode, | ||
| autofocus: widget.model.autofocus ?? false, | ||
| enabled: widget.model.enabled, | ||
| backgroundColor: widget.model.backgroundColor != null | ||
| ? WidgetStateProperty.all( | ||
| widget.model.backgroundColor!.toColor(context), | ||
| ) | ||
| : null, | ||
| side: widget.model.side?.parse(context), | ||
| innerRadius: widget.model.innerRadius != null | ||
| ? WidgetStateProperty.all(widget.model.innerRadius) | ||
| : null, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the group wiring to every Radio.
CupertinoRadio, Radio.adaptive, and Radio all require groupValue and onChanged. After removing StacRadioGroupScope, these calls no longer compile and, even if they did, taps couldn’t update the group. Please fetch the current group wiring from the new RadioGroup wrapper and feed it into each constructor.
Apply this diff to restore the required wiring:
@override
Widget build(BuildContext context) {
- switch (widget.model.radioType ?? StacRadioType.material) {
+ final radioGroup = RadioGroup.of<dynamic>(context);
+ switch (widget.model.radioType ?? StacRadioType.material) {
case StacRadioType.cupertino:
- return _buildCupertinoRadio(context);
+ return _buildCupertinoRadio(context, radioGroup?.groupValue,
+ radioGroup?.onChanged ?? (_) {});
case StacRadioType.adaptive:
- return _buildAdaptiveRadio(context);
+ return _buildAdaptiveRadio(context, radioGroup?.groupValue,
+ radioGroup?.onChanged ?? (_) {});
case StacRadioType.material:
- return _buildMaterialRadio(context);
+ return _buildMaterialRadio(context, radioGroup?.groupValue,
+ radioGroup?.onChanged ?? (_) {});
}
}
- Widget _buildCupertinoRadio(BuildContext context) {
+ Widget _buildCupertinoRadio(
+ BuildContext context,
+ dynamic groupValue,
+ ValueChanged<dynamic> onChanged,
+ ) {
return CupertinoRadio<dynamic>(
value: widget.model.value,
+ groupValue: groupValue,
+ onChanged: onChanged,
mouseCursor: widget.model.mouseCursor?.parse,
toggleable: widget.model.toggleable ?? false,
activeColor: widget.model.activeColor?.toColor(context),
inactiveColor: widget.model.inactiveColor?.toColor(context),
fillColor: widget.model.fillColor?.toColor(context),
focusColor: widget.model.focusColor?.toColor(context),
focusNode: _focusNode,
autofocus: widget.model.autofocus ?? false,
useCheckmarkStyle: widget.model.useCheckmarkStyle ?? false,
enabled: widget.model.enabled,
);
}
- Widget _buildAdaptiveRadio(BuildContext context) {
+ Widget _buildAdaptiveRadio(
+ BuildContext context,
+ dynamic groupValue,
+ ValueChanged<dynamic> onChanged,
+ ) {
return Radio<dynamic>.adaptive(
value: widget.model.value,
+ groupValue: groupValue,
+ onChanged: onChanged,
mouseCursor: widget.model.mouseCursor?.parse,
toggleable: widget.model.toggleable ?? false,
activeColor: widget.model.activeColor?.toColor(context),
fillColor: WidgetStateProperty.all(
widget.model.fillColor?.toColor(context),
),
focusColor: widget.model.focusColor?.toColor(context),
hoverColor: widget.model.hoverColor?.toColor(context),
overlayColor: WidgetStateProperty.all(
widget.model.overlayColor?.toColor(context),
),
splashRadius: widget.model.splashRadius,
materialTapTargetSize: widget.model.materialTapTargetSize?.parse,
visualDensity: widget.model.visualDensity?.parse,
focusNode: _focusNode,
autofocus: widget.model.autofocus ?? false,
useCupertinoCheckmarkStyle:
widget.model.useCupertinoCheckmarkStyle ?? false,
enabled: widget.model.enabled,
backgroundColor: widget.model.backgroundColor != null
? WidgetStateProperty.all(
widget.model.backgroundColor!.toColor(context),
)
: null,
side: widget.model.side?.parse(context),
innerRadius: widget.model.innerRadius != null
? WidgetStateProperty.all(widget.model.innerRadius)
: null,
);
}
- Widget _buildMaterialRadio(BuildContext context) {
+ Widget _buildMaterialRadio(
+ BuildContext context,
+ dynamic groupValue,
+ ValueChanged<dynamic> onChanged,
+ ) {
return Radio<dynamic>(
value: widget.model.value,
+ groupValue: groupValue,
+ onChanged: onChanged,
mouseCursor: widget.model.mouseCursor?.parse,
toggleable: widget.model.toggleable ?? false,
activeColor: widget.model.activeColor?.toColor(context),
fillColor: WidgetStateProperty.all(
widget.model.fillColor?.toColor(context),
),
focusColor: widget.model.focusColor?.toColor(context),
hoverColor: widget.model.hoverColor?.toColor(context),
overlayColor: WidgetStateProperty.all(
widget.model.overlayColor?.toColor(context),
),
splashRadius: widget.model.splashRadius,
materialTapTargetSize: widget.model.materialTapTargetSize?.parse,
visualDensity: widget.model.visualDensity?.parse,
focusNode: _focusNode,
autofocus: widget.model.autofocus ?? false,
enabled: widget.model.enabled,
backgroundColor: widget.model.backgroundColor != null
? WidgetStateProperty.all(
widget.model.backgroundColor!.toColor(context),
)
: null,
side: widget.model.side?.parse(context),
innerRadius: widget.model.innerRadius != null
? WidgetStateProperty.all(widget.model.innerRadius)
: null,
);
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart
around lines 62 to 141, each Radio constructor is missing the required group
wiring (groupValue and onChanged) after removal of StacRadioGroupScope; fetch
the current group wiring from the new RadioGroup wrapper via
RadioGroup.of(context) and pass its groupValue and onChanged into
CupertinoRadio, Radio.adaptive, and Radio constructors (handle null safely so
existing enabled/toggleable behavior remains intact); ensure the RadioGroup
import is present and remove any stale StacRadioGroupScope references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart (2)
61-75: LGTM! Change handler is correct.The method properly updates state with
setState()and synchronizes form data. The form data synchronization logic is repeated ininitState,didUpdateWidget, and here—consider extracting it to a helper method like_syncFormData(dynamic value)to reduce duplication.
77-84: LGTM! Build method is correct.The widget correctly renders
RadioGroup<dynamic>with local state and change handler. Usingdynamicprovides flexibility but reduces type safety—if radio values in a group share a specific type (e.g.,String,int), consider parameterizingRadioGroupand_groupValuewith that type to catch type errors at compile time.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/widgets/radio_group.mdx(1 hunks)packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/widgets/radio_group.mdx
🔇 Additional comments (4)
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart (4)
1-6: LGTM! Imports are appropriate.The imports cover all necessary dependencies for the refactored radio group implementation.
8-22: LGTM! Parser implementation is clean.The refactored parser correctly instantiates the private widget with positional parameters and properly retrieves the form scope.
24-32: LGTM! Widget structure is appropriate.The StatefulWidget is properly defined with a clean positional constructor.
34-46: LGTM! Initialization logic is correct.The state properly initializes
_groupValueand synchronizes with form data when an ID is provided.
| @override | ||
| void dispose() { | ||
| groupValue.dispose(); | ||
| super.dispose(); | ||
| } | ||
| void didUpdateWidget(covariant _RadioGroupWidget oldWidget) { | ||
| super.didUpdateWidget(oldWidget); | ||
| if (oldWidget.model.groupValue != widget.model.groupValue) { | ||
| _groupValue = widget.model.groupValue; | ||
|
|
||
| void _updateGroupValue(dynamic value) { | ||
| groupValue.value = value; | ||
| _saveValueInFormData(); | ||
| // Save to form data if id is provided | ||
| if (widget.model.id != null && widget.formScope != null) { | ||
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Wrap _groupValue assignment in setState().
Line 52 updates _groupValue without calling setState(), so the widget won't rebuild when groupValue changes externally (e.g., during form reset). This causes the UI to display a stale selection.
Apply this diff to trigger a rebuild:
void didUpdateWidget(covariant _RadioGroupWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.model.groupValue != widget.model.groupValue) {
- _groupValue = widget.model.groupValue;
+ setState(() {
+ _groupValue = widget.model.groupValue;
+ });
// Save to form data if id is provided
if (widget.model.id != null && widget.formScope != null) {
widget.formScope!.formData[widget.model.id!] = widget.model.groupValue;
}
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @override | |
| void dispose() { | |
| groupValue.dispose(); | |
| super.dispose(); | |
| } | |
| void didUpdateWidget(covariant _RadioGroupWidget oldWidget) { | |
| super.didUpdateWidget(oldWidget); | |
| if (oldWidget.model.groupValue != widget.model.groupValue) { | |
| _groupValue = widget.model.groupValue; | |
| void _updateGroupValue(dynamic value) { | |
| groupValue.value = value; | |
| _saveValueInFormData(); | |
| // Save to form data if id is provided | |
| if (widget.model.id != null && widget.formScope != null) { | |
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | |
| } | |
| } | |
| } | |
| @override | |
| void didUpdateWidget(covariant _RadioGroupWidget oldWidget) { | |
| super.didUpdateWidget(oldWidget); | |
| if (oldWidget.model.groupValue != widget.model.groupValue) { | |
| setState(() { | |
| _groupValue = widget.model.groupValue; | |
| }); | |
| // Save to form data if id is provided | |
| if (widget.model.id != null && widget.formScope != null) { | |
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart
around lines 48 to 59, _groupValue is updated directly in didUpdateWidget which
prevents the widget from rebuilding when groupValue changes externally; wrap the
assignment (and related stateful updates such as saving to formScope.formData)
inside setState(() { ... }) so the framework schedules a rebuild and the UI
reflects the new selection. Ensure setState only encloses mutable state changes
and leave the super.didUpdateWidget call unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart (1)
50-61: Critical: Wrap_groupValueassignment insetState().Line 54 updates
_groupValuewithout callingsetState(), so the widget won't rebuild whengroupValuechanges externally (e.g., during form reset). This causes the UI to display stale selections.Apply this diff to trigger a rebuild:
@override void didUpdateWidget(covariant _RadioGroupWidget oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.model.groupValue != widget.model.groupValue) { - _groupValue = widget.model.groupValue; + setState(() { + _groupValue = widget.model.groupValue; + }); // Save to form data if id is provided if (widget.model.id != null && widget.formScope != null) { widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart(2 hunks)
🔇 Additional comments (4)
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart (4)
1-22: LGTM: Parser and imports are correctly structured.The simplified positional constructor call and import changes align with the refactoring goals.
24-31: LGTM: Widget class correctly defined.The simplified positional constructor and state class naming are appropriate for an internal widget.
63-77: LGTM: Change handler correctly implemented.The
_onChangedmethod properly usessetState()for the value update and correctly handles form data synchronization and action callbacks.
79-86: LGTM: Build method correctly constructs RadioGroup.The widget correctly wires up
_groupValueand_onChangedto theRadioGroup, and handles the child rendering appropriately.
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| groupValue = ValueNotifier<dynamic>(widget.model.groupValue); | ||
| _saveValueInFormData(); | ||
| setState(() { | ||
| _groupValue = widget.model.groupValue; | ||
| }); | ||
|
|
||
| // Initialize form data if id is provided | ||
| if (widget.model.id != null && widget.formScope != null) { | ||
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Remove setState() from initState().
Calling setState() in initState() is incorrect because the widget hasn't been built yet. The framework will automatically schedule a build after initState() completes, so wrapping the assignment in setState() is unnecessary and violates Flutter's lifecycle contract.
Apply this diff to fix the issue:
@override
void initState() {
super.initState();
- setState(() {
- _groupValue = widget.model.groupValue;
- });
+ _groupValue = widget.model.groupValue;
// Initialize form data if id is provided
if (widget.model.id != null && widget.formScope != null) {
widget.formScope!.formData[widget.model.id!] = widget.model.groupValue;
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @override | |
| void initState() { | |
| super.initState(); | |
| groupValue = ValueNotifier<dynamic>(widget.model.groupValue); | |
| _saveValueInFormData(); | |
| setState(() { | |
| _groupValue = widget.model.groupValue; | |
| }); | |
| // Initialize form data if id is provided | |
| if (widget.model.id != null && widget.formScope != null) { | |
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | |
| } | |
| } | |
| @override | |
| void initState() { | |
| super.initState(); | |
| _groupValue = widget.model.groupValue; | |
| // Initialize form data if id is provided | |
| if (widget.model.id != null && widget.formScope != null) { | |
| widget.formScope!.formData[widget.model.id!] = widget.model.groupValue; | |
| } | |
| } |
🤖 Prompt for AI Agents
In
packages/stac/lib/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart
around lines 37 to 48, remove the call to setState() inside initState():
directly assign _groupValue = widget.model.groupValue without wrapping it in
setState, leaving the subsequent formScope initialization unchanged (i.e., keep
checking widget.model.id and widget.formScope and assigning
widget.formScope!.formData[widget.model.id!] = widget.model.groupValue).
Description
Type of Change
Summary by CodeRabbit
New Features
Refactor
Documentation