I am trying to get some values saved in the SharedPreferences from a getter method of a class. But SharedPreferences.getInstance() returns a Futu
SharedPreferences
SharedPreferences.getInstance()
Futu
You can do it in initState() and after this call setState() to update your build() method. Other way is to use FutureBuilder()
initState()
setState()
build()
FutureBuilder()
SharedPreferences sharedPrefs; @override void initState() { super.initState(); SharedPreferences.getInstance().then((prefs) { setState(() => sharedPrefs = prefs); }); }