Future<void> loadFavorite() async{
SharedPreferences prefs = await SharedPreferences.getInstance();
setState((){
FavoriteButtons = (prefs.getStringList("favorite4") ?? <bool>[]).map((value) => value == 'true').toList();
});
}
As above, using shared to store the bool list locally.
However, if you create the code as above, the list will be empty with [] when you first connect. (Because you haven't saved anything in prefs.getStringList("favorite4") yet)
I am getting the error here because I have to utilize FavoriteButtons[1]. I found a way to solve this problem. That's just using a null check error to make your code stop halfway through only the first run. As a result of testing, there is no problem with using the app. However, I wonder if there will be any problems during deployment or actual use in the future.
E/flutter (13880): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value