Closed arturjnt closed 2 years ago
I resolved this by surrounding the AuthWidgetBuilder
widget in the lib/my_app.dart
file with
FutureBuilder(
future: SharedPreferenceHelper.initSharedPrefs(),
builder: (_, __) => AuthWidgetBuilder(
And adding a static method (below) to the lib/caches/sharedpref/shared_preference_helper.dart
static Future<void> initSharedPrefs() async {
await SharedPreferences.getInstance();
}
This way, the app start waits for the shared prefs module to be loaded.
The issue is when I close and reopen my app, the color theme and language is not set according to my settings, it's always the default.
In
lib/my_app.dart
lines 40and 73
are the issue.
As these are async methods, from
lib/providers/language_provider.dart
andlib/providers/theme_provider.dart
respectively, when the app initially runs, the information isn't there yet.Let me know if anyone has thoughts how to fix it.