Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Radio groupValue and onChanged deprecated, use RadioGroup

Error'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.

  • Applies to Flutter 3.35, Dart 3.9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 radio
  2. 2Match what you see, then jump to its fix

    1. 1The analyzer shows the deprecation on Radio, RadioListTile or CupertinoRadioRadios still carry their own groupValue and onChangedFix
    2. 2You passed onChanged: null on one Radio to grey it outA radio was disabled with onChanged: nullFix
    3. 3Radios of int and String values in the same ColumnOne group mixes value typesFix

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 analyze

2Fix

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 analyze

Confirmed by docs.flutter.dev

Did this fix it?

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 run

Confirmed by docs.flutter.dev

Did this fix it?

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 run

Confirmed by api.flutter.dev

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.