lesnitsky / flutter_localstorage

📦 LocalStorage for Flutter
MIT License
301 stars 60 forks source link

Web: _readFromStorage silently crashes #54

Closed BjWe closed 3 years ago

BjWe commented 3 years ago

Hi, i am using localstorage 3.0.3+6 with

Flutter 1.24.0-7.0.pre.53 • channel master • https://github.com/flutter/flutter.git Framework • revision ee5c080d7b (57 minutes ago) • 2020-11-02 17:28:05 +0530 Engine • revision 3460519398 Tools • Dart 2.12.0 (build 2.12.0-3.0.dev)

In web.dart

Future _readFromStorage() async

the call

if (data != null)

is never reached... (Tested with Chrome debug)

This causes to not getting any stored values. - No Idea what is going wrong here

If I replace the firstWhere call with a "manual" loop it is working fine.

Orig:

 final data = localStorage.entries.firstWhere(
      (i) => i.key == fileName,
      orElse: () => null,
    );

My:

 MapEntry<String, String> data;
    localStorage.entries.forEach((element) {
      if (element.key == fileName) {
        data = element;
      }
    });

Any ideas?

lesnitsky commented 3 years ago

@BjWe I just checked web target (check out example folder) and the app works perfectly fine... perhaps something is going wrong on app-level code, not the package. Please let me know if this is still an issue