Reputation: 305
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'.
Upvotes: 3
Views: 4063
Reputation: 803
Dart supports sound null safety. Try using something like
String nonNullableString = nullableString ?? 'default';
OR
actions=uri.base.queryParameters["key"]!
Upvotes: 1
Reputation: 155
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.
final String? actions = Uri.base.queryParameters["actions"];
if (actions == null) {
/// The value of [actions] is null
return;
}
/// Continue with your coding...
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.
Upvotes: 1
Reputation: 106
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
Upvotes: 1
Reputation: 2137
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.
Upvotes: 1