rmawatson/flutter_isolate

Null data for key using encrypted_shared_preferences package

Closed this issue · 2 comments

Hi @ened @anticafe @deakjahn @stonega @nmfisher . I'm getting no data for key I stored using main thread while getting it from the spawned isolate. Please help.

After much trials I discovered you have to re-initialize the shared preferences plugin after entering isolate
Using these two plugins; add to pubspec.yaml

shared_preferences_ios: shared_preferences_android:

In your isolate function

if (Platform.isAndroid) { SharedPreferencesAndroid.registerWith(); } else if (Platform.isIOS) { SharedPreferencesIOS.registerWith(); }

Closing.