Some one can help me. Error Message: A value of type 'String?' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'.
-
Post your code. – Zakaria Hossain Mar 23 '22 at 08:41
-
Check my answer : https://stackoverflow.com/questions/71555669/flutter-router-the-argument-type-string-cant-be-assigned-to-the-parameter/71555872#71555872 – Yashraj Mar 23 '22 at 08:42
-
[Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551) – tareq albeesh Mar 23 '22 at 08:50
-
Does this answer your question? [Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't](https://stackoverflow.com/questions/66798782/error-the-argument-type-string-cant-be-assigned-to-the-parameter-type-stri) – Ahmad F Mar 23 '22 at 08:51
-
https://dart.dev/guides/language/sound-problems – Furkan Mar 23 '22 at 09:12
4 Answers
Dart supports sound null safety. Try using something like
String nonNullableString = nullableString ?? 'default';
OR
actions=uri.base.queryParameters["key"]!

- 633
- 6
- 16
-
You can find more info in https://github.com/flutter/flutter/issues/92792 – Naveen Kulkarni Mar 23 '22 at 08:46
-
-
In all the 3 places you are getting. use `actions=uri.base.queryParameters["key"]!` – Naveen Kulkarni Mar 23 '22 at 13:46
Check some points with null safety declaration of data member of class. And also check out the type of action parameter what it takes- It may take String type of data then update your variables/data member accordingly.
Please look into the concept of null safety.

- 1,852
- 1
- 6
- 9
Use Null Safely
code as this:
action = Uri.base.queryParameters['action']!; // add ! mark
The same process for all errors:
encryptedEmailAddress = Uri.base.queryParameters['encryptedEmailAddress']!; // add ! mark
doctorUID = Uri.base.queryParameters['doctorUID']!; // add ! mark

- 116
- 2
- 4
- 18
As dart uses sound null safety, there are chances that the value in Uri.base.queryParameters["actions"]
can be null. This is something that Flutter has adapted from the Swift programming language.
So basically, there are 2 ways you can solve this problem.
- Using the null check.
final String? actions = Uri.base.queryParameters["actions"];
if (actions == null) {
/// The value of [actions] is null
return;
}
/// Continue with your coding...
- By providing an optional value.
final String _actions = Uri.base.queryParameters["actions"] ?? "defaultValue";
I hope you understood what I am trying to say.
If you have any other doubts, do let me know.

- 105
- 2
- 4