Cannot change value of a RadioListButton

Solution for Cannot change value of a RadioListButton
is Given Below:

enter image description here

I get the error

A value of type ‘Object?’ can’t be assigned to a variable of type

I’m sure the solution here is very simple but I’m new to flutter so if anyone has any suggestions and resources/links it would be highly appreciated.

  class MyAppState extends State<MyApp> {
  final _usernameController = TextEditingController();
  var _selectedGender = Gender.FEMALE;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: Text("User Settings"),
            ),
            body: ListView(children: [
              ListTile(
                  title: TextField(
                controller: _usernameController,
                decoration: InputDecoration(labelText: "Username"),
              )),
              RadioListTile(
                  value: Gender.MALE,
                  groupValue: _selectedGender,
                  onChanged: (newValue) => setState(() => _selectedGender = newValue)),
            ])));
  }
}

You need to define the type parameter of RadioListTile as being Gender:

//           vvvvvvvv
RadioListTile<Gender>(
  value: Gender.MALE,
  groupValue: _selectedGender,
  onChanged: (newValue) => setState(() => _selectedGender = newValue),
),

You also need to handle null as a parameter of the onChanged callback:

RadioListTile<Gender>(
  value: Gender.MALE,
  groupValue: _selectedGender,
  onChanged: (newValue) {
    // If the newValue is null, do nothing
    if (newValue == null) return;
    setState(() => _selectedGender = newValue);
  },
),

Additional reading: The Dart type system