Closed wujek-srujek closed 3 years ago
had same issue
It seems the example here: https://github.com/Cretezy/redux_persist/blob/master/packages/redux_persist_flutter/example/redux_persist_flutter_example.dart doesn't work. First, it requires the
WidgetsFlutterBinding.ensureInitialized();
call because otherwise it fails with:Unhandled Exception: StorageException: On load: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first. If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.
When the line is added, it fails with:
Unhandled Exception: SerializationException: On load: NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: []("counter")
That's because this function: https://github.com/Cretezy/redux_persist/blob/master/packages/redux_persist_flutter/example/redux_persist_flutter_example.dart#L38 doesn't handle
null
, which is the initial value the first time the application is ever launched. Same issue. Have you found solution?
@DmitriyGribennikov yes, just add WidgetsFlutterBinding.ensureInitialized();
somewhere before your code using this library if you don't have it yet for the first issue. Add a null
check for the second issue.
But personally I've migrated away from this library as it seems pretty abandoned, the last commit on master is 6 months old, and nobody answers to issues at all. (Actually, I've migrated away from Redux in general, not a big fan.)
This should be added to the readme/example on https://pub.dev/packages/redux_persist !
It seems the example here: https://github.com/Cretezy/redux_persist/blob/master/packages/redux_persist_flutter/example/redux_persist_flutter_example.dart doesn't work. First, it requires the
WidgetsFlutterBinding.ensureInitialized();
call because otherwise it fails with:When the line is added, it fails with:
That's because this function: https://github.com/Cretezy/redux_persist/blob/master/packages/redux_persist_flutter/example/redux_persist_flutter_example.dart#L38 doesn't handle
null
, which is the initial value the first time the application is ever launched.