I'm making a radio button then i face this error.//A value of type 'Object?' can't be assigned to a variable of type 'SigninCharacter'. Try changing the type of the variable, or casting the right-hand type to 'SigninCharacter'.\
enum SigninCharacter { fill, outline }
class productOverVeiw extends StatefulWidget {
const productOverVeiw({Key? key}) : super(key: key);
@override
State<productOverVeiw> createState() => _productOverVeiwState();
}
class _productOverVeiwState extends State<productOverVeiw> {
SigninCharacter _character = SigninCharacter.fill;
Radio(
value: SigninCharacter.fill,
groupValue: _character,
activeColor: Colors.green,
onChanged: (value) {
setState(() {
_character = value ;//A value of type 'Object?' can't be assigned to a variable of type 'SigninCharacter'. Try changing the type of the variable, or casting the right-hand type to 'SigninCharacter'.\
});
})
Try this just add the value type SigninCharacter to value:
Radio(
value: SigninCharacter.fill,
groupValue: _character,
activeColor: Colors.green,
onChanged: (SigninCharacter? value) { // <--- assign it here
setState(() {
_character = value!; // and add ! to value
});
})