Closed vishant-jaiswal closed 5 years ago
i get a similar error when i start the app the first time. then persistor.load() throws a error. i fixed it with the following code:
try { initialState = await persistor.load(); } catch (e) { // ; }
here is my old code:
` final persistor = Persistor
final initialState = await persistor.load();
final store = Store
here the error message with debug mode on:
`I/flutter (16048): Persistor debug: Starting load...
I/flutter (16048): Persistor debug: Loading from storage
I/flutter (16048): Persistor debug: Running load raw transformations
I/flutter (16048): Persistor debug: Deserializing
I/flutter (16048): Persistor debug: Error while loading: SerializationException: On load: NoSuchMethodError: The method '[]' was called on null.
I/flutter (16048): Receiver: null
I/flutter (16048): Tried calling:
E/flutter (16048): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (16048): SerializationException: On load: NoSuchMethodError: The method '[]' was called on null.
E/flutter (16048): Receiver: null
E/flutter (16048): Tried calling:
E/flutter (16048): #0 Persistor.load (package:redux_persist/src/persistor.dart:131:7)
E/flutter (16048):
E/flutter (16048): #1 main (package:test/main.dart:30:40)
E/flutter (16048):
E/flutter (16048): #2 _startIsolate.
(dart:isolate/runtime/libisolate_patch.dart:289:19)
E/flutter (16048): #3 _RawReceivePortImpl._handleMessage
(dart:isolate/runtime/libisolate_patch.dart:171:12)`
The error is thrown from you serializer, as seen with SerializationException
. Are you calling .first
in your serializer?
Don't forget that serializer must handle null cases. Data coming in/out must be able to accept null or empty data, and fallback gracefully.
I am getting following error while loading
E/flutter (26697): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception: E/flutter (26697): SerializationException: On load: NoSuchMethodError: The getter 'first' was called on null. E/flutter (26697): Receiver: null E/flutter (26697): Tried calling: first E/flutter (26697): #0 Persistor.load (package:redux_persist/src/persistor.dart:131:7) E/flutter (26697):
E/flutter (26697): #1 main (package:samco_app/main.dart:39:40)
E/flutter (26697):
E/flutter (26697): #2 _startIsolate. (dart:isolate/runtime/libisolate_patch.dart:289:19)
E/flutter (26697): #3 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)