Flutter: null safety updates get me some errors in code

Issue

I have a project was made before null safety, now the code has a lot of errors
I was fixed all error except this two errors shown below, and I’m not sure what should I do about this

The first error:
The first error:

===============================

The Second error:
The Second error

Thanks in advance

Solution

You can use a null-able value like String? _token. Because it can be a null value before initializing the value.
Or you can use a late keyword to init later, but you shouldn’t use this before init.

For more info, reference the Null safety in Dart video.

Answered By – MaNDOOoo

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.