Error: A value of type 'String?' can't be assigned to a variable of type 'String'

Issue

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’.

enter image description here

Solution

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

Answered By – Mouaz M Shahmeh

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.