Cretezy / redux_persist

Persist Redux State
https://pub.dartlang.org/packages/redux_persist
MIT License
130 stars 41 forks source link

On load: Concurrent modification during iteration: Instance(length:3) of '_GrowableList'. #33

Closed inquisitev closed 5 years ago

inquisitev commented 5 years ago

void main() async{

final persistor = Persistor( storage: FlutterStorage(key: "GMWAN_AppState.json", location: FlutterSaveLocation.sharedPreferences), // Or use other engines serializer: JsonSerializer(GMWAN_AppState.fromJson), // Or use other serializers );

// Load initial state /*

final initalStateCompleter = Completer();

persistor.load().then((store){ initalStateCompleter.complete(store); }).catchError((c){ print('ERRRRROOOOOORRRRRRR--------------------------------------------'); initalStateCompleter.complete(GMWAN_AppState(userState: ParticleUserState(user: ParticleUser.notLoggedIn()),infoCardsState: InfoCardsState())); });

*/

final initialState = await persistor.load();

final store = new Store( appStateReducer, initialState: initialState ?? GMWAN_AppState(userState: ParticleUserState(user: ParticleUser.notLoggedIn()),infoCardsState: InfoCardsState()), middleware: [thunkMiddleware, persistor.createMiddleware()]);

runApp(StoreProvider( child: MyApp(), store: store, )); }

Above is my main method. The thunk middle ware is an async network call that builds a list on response.

[VERBOSE-2:shell.cc(186)] Dart Error: Unhandled exception: SerializationException: On load: Concurrent modification during iteration: Instance(length:3) of '_GrowableList'.

0 Persistor.load (package:redux_persist/src/persistor.dart:131:7)

#1 main (package:gmwan/GMWAN_Redux/mainRedux.dart:37:40) #2 _startIsolate. (dart:isolate/runtime/libisolate_patch.dart:289:19) #3 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12) Please advise on what i should do to fix this error. Thank you!
Cretezy commented 5 years ago

This seems to happen because you are calling load twice. Try with just one

Cretezy commented 5 years ago

Feel free to reopen the issue if this doesn't fix it!