Radio groupValue and onChanged deprecated, use RadioGroup
'groupValue' is deprecated and shouldn't be used.Short answer
Since Flutter 3.35, Radio.groupValue and Radio.onChanged are deprecated. Wrap the radios in a RadioGroup that owns groupValue and onChanged, and leave each Radio with just its value. To disable one radio, pass enabled: false. Radios of different value types need one RadioGroup per type.
Fix it fast
1Find out which cause you have
Find every use of the deprecated properties, including on RadioListTile and CupertinoRadio, which are in the same change.
grep -rn "groupValue\|onChanged" lib/ | grep -i radio2Match what you see, then jump to its fix
- 1
The analyzer shows the deprecation on Radio, RadioListTile or CupertinoRadioRadios still carry their own groupValue and onChangedFix - 2
You passed onChanged: null on one Radio to grey it outA radio was disabled with onChanged: nullFix - 3
Radios of int and String values in the same ColumnOne group mixes value typesFix
- 1
What does the error look like?
'groupValue' is deprecated and shouldn't be used.'onChanged' is deprecated and shouldn't be used.
Cause 1 of 3
Radios still carry their own groupValue and onChanged
1Check
The breaking-change page lists Radio, CupertinoRadio and RadioListTile groupValue and onChanged as deprecated in 3.35.
dart analyze2Fix
Move groupValue and onChanged to one RadioGroup around the radios.
RadioGroup<int>(
groupValue: _groupValue,
onChanged: (int? value) {
setState(() { _groupValue = value; });
},
child: Column(
children: <Widget>[
Radio<int>(value: 0),
Radio<int>(value: 2),
],
),
)3Verify
The deprecation warnings disappear.
dart analyzeConfirmed by docs.flutter.dev
Cause 2 of 3
A radio was disabled with onChanged: null
1Check
That pattern no longer applies once the callback moves to the group.
grep -rn "onChanged: null" lib/2Fix
Pass enabled: false on the Radio itself.
Radio<int>(value: 2, enabled: false)3Verify
The radio shows disabled and ignores taps.
flutter runConfirmed by docs.flutter.dev
Cause 3 of 3
One group mixes value types
1Check
A RadioGroup only covers radios of its own type T, so another type is not part of it.
grep -rn "Radio<" lib/2Fix
Add one RadioGroup per value type and nest them.
RadioGroup<String>(
groupValue: _stringValue,
onChanged: (String? v) => setState(() { _stringValue = v; }),
child: Column(children: [Radio<String>(value: 'a'), Radio<String>(value: 'b')]),
)3Verify
Each group selects independently.
flutter runConfirmed by api.flutter.dev
How do I stop it coming back?
- Run dart analyze after each Flutter upgrade and fix deprecations in the same change.
- Keep one RadioGroup per question or value type.
- Read the breaking-change page for a widget before rewriting it by hand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
FlatButton, RaisedButton and OutlineButton no longer work in Flutter
FlatButton
FlatButton, RaisedButton and OutlineButton were replaced by TextButton, ElevatedButton and OutlinedButton.
3 causes, each with a fixMobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fix