lesnitsky / flutter_localstorage

📦 LocalStorage for Flutter
MIT License
299 stars 65 forks source link

Localstorage ready not gets called when using flutter_test #77

Closed Y0ngg4n closed 6 months ago

Y0ngg4n commented 3 years ago

Hello together i am trying using flutter_test. But with localstorage only my first localstorage.ready callback gets called. Here some snippets of my code

final LocalStorage accountStorage = new LocalStorage('account');
final LocalStorage introStorage = new LocalStorage('intro');
final LocalStorage settingsStorage = new LocalStorage('settings');

@override
  void initState() {
    super.initState();
    WidgetsBinding.instance!.addPostFrameCallback((_) => {
          setState(() {
            accountStorage.ready.then((value) => {_setStorageReady()});
            introStorage.ready.then((value) => {_setIntroStorageReady()});
            settingsStorage.ready.then((value) =>  {print("Settingstorage is ready")});
          })
        });
}

So when i run this code normally it works fine but with flutter_test only the first callback _setStorageReady() gets called. introStorage and settingsStorage never get that callback.

lesnitsky commented 6 months ago

Please migrate to the latest version, the API is fully synchronous now.