Does anyone can help my problem ?
I have a Flutter script below :
ListTile(
title: const Text("Change Password"),
trailing: const Icon(Icons.lock),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ChangePassword(
value: value, key: null,
)));
},
),
that script is calling the routine below :
class ChangePassword extends StatefulWidget { List value; ChangePassword({required Key key, required this.value}) : super(key: key);
And i’ve got an error message :
"The argument type ‘Null’ can’t be assigned to the parameter type ‘Key’"
how do i solve my problem ?
Thanks in advance,
Tono.
i don’t have any idea….
3
Answers
You should do the key parameter is nullable, like this:
class ChangePassword extends StatefulWidget { List value; ChangePassword({Key? key, required this.value}) : super(key: key);
You have two options here.
I recommend to use the first one. And I think you have deleted the "?" after key by mistake.
just set your key like this key:Key(”)