LateInitializationError: Field 'prefs' has not been initialized

32 Views Asked by At

I use sharedpreferences like this


Why wrong? what initialized..?

1

There are 1 best solutions below

0
Francesco - FL On

Before using the SharedPreferences variable, you need to initialize it:

_prefs = await SharedPreferences.getInstance();

Then you can use the variable.