A fast, extra light and synchronous key-value storage to Get framework

Overview

get_storage

A fast, extra light and synchronous key-value in memory, which backs up data to disk at each operation. It is written entirely in Dart and easily integrates with Get framework of Flutter.

Supports Android, iOS, Web, Mac, Linux, and fuchsia and Windows**. Can store String, int, double, Map and List

Add to your pubspec:

dependencies:
  get_storage:

Install it

You can install packages from the command line:

with Flutter:

$  flutter packages get

Import it

Now in your Dart code, you can use:

import 'package:get_storage/get_storage.dart';

Initialize storage driver with await:

main() async {
  await GetStorage.init();
  runApp(App());
}

use GetStorage through an instance or use directly GetStorage().read('key')

final box = GetStorage();

To write information you must use write :

box.write('quote', 'GetX is the best');

To read values you use read:

print(box.read('quote'));
// out: GetX is the best

To remove a key, you can use remove:

box.remove('quote');

To listen changes you can use listen:

box.listen((){
  print('box changed');
});

If you subscribe to events, be sure to dispose them when using:

box.removeListen(listen);

To listen changes on key you can use listenKey:

box.listenKey('key', (value){
  print('new key is $value');
});

To erase your container:

box.erase();

If you want to create different containers, simply give it a name. You can listen to specific containers, and also delete them.

GetStorage g = GetStorage('MyStorage');

To initialize specific container:

await GetStorage.init('MyStorage');

SharedPreferences Implementation

class MyPref {
  static final _otherBox = () => GetStorage('MyPref');

  final username = ''.val('username');
  final age = 0.val('age');
  final price = 1000.val('price', getBox: _otherBox);

  // or
  final username2 = ReadWriteValue('username', '');
  final age2 = ReadWriteValue('age', 0);
  final price2 = ReadWriteValue('price', '', _otherBox);
}

...

void updateAge() {
  final age = 0.val('age');
  // or 
  final age = ReadWriteValue('age', 0, () => box);
  // or 
  final age = Get.find<MyPref>().age;

  age.val = 1; // will save to box
  final realAge = age.val; // will read from box
}

Benchmark Result:

GetStorage is not fast, it is absurdly fast for being memory-based. All of his operations are instantaneous. A backup of each operation is placed in a Container on the disk. Each container has its own file.

What GetStorage is:

Persistent key/value storage for Android, iOS, Web, Linux, Mac and Fuchsia and Windows, that combines fast memory access with persistent storage.

What GetStorage is NOT:

A database. Get is super compact to offer you a solution ultra-light, high-speed read/write storage to work synchronously. If you want to store data persistently on disk with immediate memory access, use it, if you want a database, with indexing and specific disk storage tools, there are incredible solutions that are already available, like Hive and Sqflite/Moor.

As soon as you declare "write" the file is immediately written in memory and can now be accessed immediately with box.read(). You can also wait for the callback that it was written to disk using await box.write().

When to use GetStorage:

  • simple Maps storage.
  • cache of http requests
  • storage of simple user information.
  • simple and persistent state storage
  • any situation you currently use sharedPreferences.

When not to use GetStorage:

  • you need indexes.
  • when you need to always check if the file was written to the storage disk before starting another operation (storage in memory is done instantly and can be read instantly with box.read(), and the backup to disk is done in the background. To make sure the backup is complete, you can use await, but if you need to call await all the time, it makes no sense you are using memory storage).

You can use this lib even as a modest persistent state manager using Getx SimpleBuilder

Comments
  • Await asynchronous calls in benchmark

    Await asynchronous calls in benchmark

    https://github.com/jonataslaw/get_storage/blob/master/storage_benchmark/lib/runners/get_storage.dart#L55

    Your writes/deletes are not synchronous. You have to await them, or your benchmark lacks validity. Dart's stopwatch class, right now, is simply measuring the queuing time for a Future + read/write/delete time from an in-memory hashmap.

    (Alternatively, you could make writes/deletes synchronous by using File.writeAsStringSync(), but this isn't recommended.)

    On another note, I find it vaguely concerning that you awaited every other library's operations (i.e. measured them properly), but exempted your own from proper measurement.

    opened by AKushWarrior 16
  • GetStorage strange behaviour in unit tests

    GetStorage strange behaviour in unit tests

    I am writing unit tests for my implementation of GetStorage shared preferences alongside GetX and it would be so helpful to see how to properly use both GetStorage and GetX controllers in unit tests. I see some very inconsistent GetStorage behaviour in my unit tests - sometimes the data gets updated, other times not and most of the time the data persists until another test is run, even though I initialize the class from scratch every time .

    The unit test does not pick up the correct values inside the variables. For example, both userData.firstName.val, errorController.contactInfoMissing.value inside the test even though I confirmed they are both being set with correct values in the code. This leads me to believe that I may doing something wrong inside the unit test, but there is no documentation on how to do it properly.

    P.S. StoredUserData works fine in my app, but for some reason not in the unit test.

    Also, I wasn't able to initialize the ErrorController inside the setUp of the unit test. StoredUserData is not finding it in this case, therefore I had to initialize it in the test itself - not sure if proper.

    Unit test code

    class MockDocumentSnapshot extends Mock implements DocumentSnapshot {
      Map<String, dynamic> mockData;
      MockDocumentSnapshot(this.mockData);
    
      @override
      Map<String, dynamic> data() {
        return mockData;
      }
      @override
      bool get exists => true;
    }
    
    class MockFirestoreService extends Mock implements FirestoreService {
      final MockDocumentSnapshot documentSnapshot;
    
      MockFirestoreService(this.documentSnapshot);
      @override
      Future<MockDocumentSnapshot> readData(String collectionName, String documentPath) {
        return Future.delayed(Duration(milliseconds: 0)).then((value) => documentSnapshot);
      }
    }
    
    void main() {
      setupCloudFirestoreMocks();
    
      setUpAll(() async {
        TestWidgetsFlutterBinding.ensureInitialized();
        await Firebase.initializeApp();
     await GetStorage.init();
    
      });
     test(
            'update() method test: blank data, lastUpdatedDate is today and force update is true - update should run and contactInfoMissing value should be set to true',
            () {
          ErrorController errorController = Get.put(ErrorController());
          const Map<String, dynamic> blankUserAccountData = {};
          MockDocumentSnapshot mockDocumentSnapshot = MockDocumentSnapshot(blankUserAccountData);
    
          MockFirestoreService mockFirestoreService = MockFirestoreService(mockDocumentSnapshot);
          final StoredUserData userData = StoredUserData(firestoreService: mockFirestoreService);
    await userData.erase();
          String today = DateTime.now().toString();
          userData.lastUpdated.val = today;
          // userData.erase();
          userData.update(true, 'email', 'UID');
          expect(userData.firstName.val, '');
          expect(userData.lastName.val, '');
          expect(userData.aptNumber.val, '');
          expect(userData.streetNumber.val, '');
          expect(userData.streetName.val, '');
          expect(userData.city.val, '');
          expect(userData.loginEmail.val, '');
          expect(userData.contactEmail.val, '');
          expect(userData.phone.val, '');
          expect(userData.visibility.val, {});
          expect(userData.languages.val, []);
          expect(userData.lastUpdated.val, DateTime.utc(2020, DateTime.november, 11).toString());
    
          expect(errorController.contactInfoMissing.value, true);
    
          Get.delete<ErrorController>();
        });
    }
    

    Code being tested:

    class StoredUserData {
      ErrorController _errorController = Get.find<ErrorController>();
      FirestoreService _firestoreService = FirestoreService();
     
     StoredUserData({FirestoreService firestoreService}) : this.firestoreService = firestoreService ?? FirestoreService();
      static final _userDataBox = () => GetStorage('UserData');
    
      final firstName = ReadWriteValue(kdbFieldFirstName, '', _userDataBox);
      final lastName = ReadWriteValue(kdbFieldLastName, '', _userDataBox);
      final aptNumber = ReadWriteValue(kdbFieldAptNumber, '', _userDataBox);
      final streetNumber = ReadWriteValue(kdbFieldStreetNum, '', _userDataBox);
      final streetName = ReadWriteValue(kdbFieldStreetName, '', _userDataBox);
      final city = ReadWriteValue(kdbFieldCity, '', _userDataBox);
      final loginEmail = ReadWriteValue('loginEmail', '', _userDataBox);
      final contactEmail = ReadWriteValue(kdbFieldEmail, '', _userDataBox);
      final phone = ReadWriteValue(kdbFieldPhone, '', _userDataBox);
      final visibility = ReadWriteValue(kdbFieldVisibility, {}, _userDataBox);
      final languages = ReadWriteValue(kdbFieldLanguages, [], _userDataBox);
      final lastUpdated = ReadWriteValue('lastUpdated', DateTime.utc(2020, DateTime.november, 11).toString(), _userDataBox);
    
      Future<Map<String, dynamic>> getFreshDataFromDB(String userID) async {
        Map<String, dynamic> _userSnapshotData;
        
        await _firestoreService.readData(kdbCollUserAccounts, userID).then((docSnapshot) => _userSnapshotData = docSnapshot.data()).catchError((error) {
         
          _errorController.errorMessage.value = error.toString();
        });
       
        return _userSnapshotData;
      }
    
      void update(bool forceUpdate, String userEmail, String userID) async {
        
        
        final DateTime today = DateTime.now();
        final DateTime _lastUpdated = DateTime.parse(lastUpdated.val);
       
        if (_userDataBox.isNullOrBlank || _lastUpdated.difference(today).inDays < -1 || forceUpdate) {
          print('GetX Storage Called: date test is true');
          try {
           
            Map<String, dynamic> _userSnapshotData = await getFreshDataFromDB(userID);
            print('GetX Storage Called: usersnapshotdata after getFreshDataCalled - $_userSnapshotData');
            if (_userSnapshotData != null) {
              lastUpdated.val = DateTime.now().toString();
              Map _address = _userSnapshotData[kdbFieldAddress];
              Map _contactInfo = _userSnapshotData[kdbFieldContactInfo];
              print('GetX Storage Called: first name before update - ${firstName.val}; DateTime: ${DateTime.now().toString()}');
              print('GetX Storage Called: last name before update - ${lastName.val}; DateTime: ${DateTime.now().toString()}');
              firstName.val = _userSnapshotData[kdbFieldFirstName].toString();
              lastName.val = _userSnapshotData[kdbFieldLastName].toString();
             
              if (_address.isNullOrBlank) {
                _errorController.contactInfoMissing.value = true;
                lastUpdated.val = DateTime.utc(2020, DateTime.november, 11).toString();
               } else {
                _errorController.contactInfoMissing.value = false;
                aptNumber.val = !_address.isNullOrBlank ? _address[kdbFieldAptNumber] : '';
                streetNumber.val = !_address.isNullOrBlank ? _address[kdbFieldStreetNum] : '';
                streetName.val = !_address.isNullOrBlank ? _address[kdbFieldStreetName] : '';
                city.val = !_address.isNullOrBlank ? _address[kdbFieldCity] : '';
              }
              loginEmail.val = userEmail;
             if (!_contactInfo.isNullOrBlank) {
                String _email = _contactInfo[kdbFieldEmail];
    
                contactEmail.val = _email.isNullOrBlank ? userEmail : _email;
                phone.val = _contactInfo[kdbFieldPhone];
              } else {
                contactEmail.val = userEmail;
                phone.val = '';
              }
                 visibility.val = _userSnapshotData[kdbFieldVisibility] ?? {};
              languages.val = _userSnapshotData[kdbFieldLanguages] ?? [];
            }
          } catch (e) {
            print('GetX Storage Called: error caught - ${e.toString()}');
            _errorController.errorMessage.value = e.toString();
          }
        } else {
          print('GetX Storage Called: UserData was updated less than one day ago');
        }
     void erase() async {
        await GetStorage('UserData').erase();
        print('GetStorage.erase() called');
      }
       
      }
    
    
    opened by yulkin2002 13
  • [BUG] Error on GetStorage.init();

    [BUG] Error on GetStorage.init();

    void main() async {
      await GetStorage.init();
      // await dotenv.load();
      runApp(MyApp());
    }
    
    MissingPluginException (MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider))
    
    E/flutter (10909): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on
    channel plugins.flutter.io/path_provider)
    [        ] E/flutter (10909): #0      GetStorage._init (package:get_storage/src/storage_impl.dart:47:7)
    [        ] E/flutter (10909): <asynchronous suspension>
    [        ] E/flutter (10909): #1      new GetStorage._internal.<anonymous closure> (package:get_storage/src/storage_impl.dart:28:7)
    [        ] E/flutter (10909): <asynchronous suspension>
    [        ] E/flutter (10909): #2      main (package:bjj_library/main.dart:18:3)
    [        ] E/flutter (10909): <asynchronous suspension>
    [        ] E/flutter (10909): 
    
    
    opened by gaetan1903 4
  • Broken test on master - has been for a while

    Broken test on master - has been for a while

    https://github.com/jonataslaw/get_storage/runs/956543996?check_suite_focus=true

    00:43 +0 -1: loading /Users/runner/work/get_storage/get_storage/test/getstorage_test.dart [E]                                                                                                          
      Failed to load "/Users/runner/work/get_storage/get_storage/test/getstorage_test.dart": MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
      package:get_storage/src/storage_impl.dart 48:7   GetStorage._init
      ===== asynchronous gap ===========================
      package:get_storage/src/storage_impl.dart 28:13  new GetStorage._internal.<fn>
      
    
    00:43 +0 -1: Some tests failed.                                                                                                                                                                        
    ##[error]Process completed with exit code 1.
    
    opened by ghost 4
  • Tests breaking due to path provider on GetStorage.init()

    Tests breaking due to path provider on GetStorage.init()

    I'm getting this error when I call GetStorage.init()

    Failed to load "/test/app/utils/database_test.dart": MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider) GetStorage._init package:get_storage/src/storage_impl.dart:47 ===== asynchronous gap =========================== new GetStorage._internal.<fn> package:get_storage/src/storage_impl.dart:28 ===== asynchronous gap =========================== main test/…/utils/database_test.dart:16 ===== asynchronous gap =========================== /var/folders/tb/1s9dn9sd7xz414ft8llkr7dc0000gn/T/flutter_tools.CrFDe3/flutter_test_listener.4A6vdQ/listener.dart 19:3 _testMain

    checking previous issues of the same it was fixed but it's still surfacing

    opened by materoy 3
  • Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

    Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

    As I'm using the get_storage in my app, my app freezes on the startup showing the white screen while building the release apk. Getting the following error:

    [+2458 ms] E/flutter (11801): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception:
    MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel        
    plugins.flutter.io/path_provider)
    [   +2 ms] E/flutter (11801): #0      GetStorage._init (package:get_storage/src/storage_impl.dart:47)        
    [   +1 ms] E/flutter (11801): <asynchronous suspension>
    [   +1 ms] E/flutter (11801): #1      new GetStorage._internal.<anonymous closure>
    (package:get_storage/src/storage_impl.dart:28)
    [   +1 ms] E/flutter (11801): <asynchronous suspension>
    [   +1 ms] E/flutter (11801): #2      Initializer._initStorage
    (package:scm_study/app/common/util/initializer.dart:22)
    [   +1 ms] E/flutter (11801): <asynchronous suspension>
    [        ] E/flutter (11801): #3      Initializer.init
    (package:scm_study/app/common/util/initializer.dart:12)
    [   +1 ms] E/flutter (11801): <asynchronous suspension>
    [   +1 ms] E/flutter (11801): #4      main (package:scm_study/main.dart:13)
    [        ] E/flutter (11801): <asynchronous suspension>
    [   +1 ms] E/flutter (11801): 
    
    opened by thealteria 3
  • Cant read Storage on onInit()

    Cant read Storage on onInit()

    so i have this simple controller, and in onInit box.read('citys') is null, i dont know why, is it a bug, how do i get the value in onInit and assign it to something?

    with the getter of my controller, i am able to get the value from storage.

    (First time this runs, it should be null, but secondtime it should return the stored value, its there i get it from the getter)

    controller.dart

    import 'package:get/get.dart';
    import 'package:get_storage/get_storage.dart';
    
    class TestController extends GetxController {
      final box = GetStorage();
      String get stringtext => box.read('citys') ?? "nux";
    
      @override
      void onInit() {
        print(box.read('citys')); // returns null ?????
        print('write');
        box.write('citys', 'Hallo!!');
        super.onInit();
      }
    }
    

    main.dart

    import 'package:flutter/material.dart';
    import 'package:get/get.dart';
    import 'controller.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      final TestController testController = Get.put(TestController());
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: Scaffold(
            body: Center(
              child: SimpleBuilder(
                builder: (_) {
                  return Text(testController.stringtext);
                },
              ),
            ),
          ),
        );
      }
    }
    
    opened by ingomc 3
  • read write value, kotlin delegate style

    read write value, kotlin delegate style

    I've been using get_storage and found it very helpful. I think I have a nice implementation to add to make it easier to use. Inspired by kotlin ReadWrite delegate. So a simple get or set will directly access box.

    class MyPref {
      static final _otherBox = () => GetStorage('MyPref');
    
      final username = ''.val('username');
      final age = 0.val('age');
      final price = 1000.val('price', getBox: _otherBox);
    
      // or
      final username2 = ReadWriteValue('username', '');
      final age2 = ReadWriteValue('age', 0);
      final price2 = ReadWriteValue('price', '', _otherBox);
    }
    
    ...
    
    void updateAge() {
      final age = 0.val('age');
      // or 
      final age = ReadWriteValue('age', 0, () => box);
      // or 
      final age = Get.find<MyPref>().age;
    
      age.val = 1; // will save to box
      final realAge = age.val; // will read from box
    }
    
    opened by alifgiant 3
  • app freezes on the splash screen in release mode

    app freezes on the splash screen in release mode

    after coule of days I figure I have an issue using get_storage , the app work well until I signin , this because I save the login data using get_storage , the splash screen freezes after opening and closing the app multiple times this only happen in the release mode flutter 2.10.2. tested on real device

    the main.dart

    `import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import 'package:talab/helpers/translation/LocalizationService.dart'; import 'package:talab/helpers/constant_helper.dart'; import 'package:talab/helpers/binging_helper.dart'; import 'modules/settings/controllers/settings_controller.dart'; import 'modules/users/controllers/login_controller.dart'; import 'modules/users/services/auth_service.dart';

    initServices() async { Get.log('starting services ...'); await GetStorage.init(); await Get.putAsync(() => AuthService().init()); Get.put(SettingsController(),permanent: true).init(); Get.put(LoginController()).init(); Get.log('All services started...'); }

    void main() async { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, // transparent status bar )); await initServices(); runApp(MyApp()); }

    class MyApp extends StatelessWidget {

    const MyApp();

    @override Widget build(BuildContext context) { return GestureDetector( onTap: () { hideKeyboard(context); }, child: GetMaterialApp( initialRoute: AppPages.INITIAL, getPages: AppPages.routes, enableLog: true, debugShowCheckedModeBanner: false, title: Config.AppName, theme: AppThemes.appTheme, locale: LocalizationService.locale, fallbackLocale: LocalizationService.fallbackLocale, translations: LocalizationService(), ), ); } void hideKeyboard(BuildContext context) { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { FocusManager.instance.primaryFocus.unfocus(); } } } `

    the authService.dart

    `import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import '../models/user.dart';

    class AuthService extends GetxService { final user = User().obs; GetStorage _box;

    AuthService() { _box = new GetStorage(); }

    Future init() async { user.listen((User _user) { _box.write('current_user', _user.toJson()); }); await getCurrentUser(); return this; }

    Future getCurrentUser() async { //this.removeCurrentUser(); if (user.value.auth == null && _box.hasData('current_user')) { var map1 = await _box.read('current_user'); map1.update('status', (value) => value.toString()); user.value = User.fromJson(map1); user.value.auth = true; } else { user.value.auth = false; } print(user.value); }

    Future removeCurrentUser() async { user.value = new User(); await _box.remove('current_user'); } bool get isAuth => user.value.auth ?? false;

    //String get apiToken => (user.value.auth ?? false) ? user.value.apiToken : ''; } `

    opened by webeasystep 2
  • set location of Getstorage box files

    set location of Getstorage box files

    I use Getstorage in macos and it works great, however the location of the box files is always your Documents folder. This is the case for any macos app using Getstorage. Anyway to change this file location?

    opened by mpierog 2
  • FileSystemException on Windows

    FileSystemException on Windows

    Hello! Error is thrown on Windows 10.

    [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FileSystemException: lock failed, path = 'C:\Users\win10\Documents/GetStorage.gs'

    • get_storage: 1.4.0
    • flutter: 2.0.1

    Error is thrown when calling GetStorage.wrile(...) second and next times after app lauched.

    opened by qwert2603 2
  • Converting object to an encodable object failed: _LinkedHashMap len:3

    Converting object to an encodable object failed: _LinkedHashMap len:3

    I/flutter (31134): ---translateMap, {169: ha ha, 167: Just now} I/flutter (31134): ----------------FIREBASE CRASHLYTICS---------------- I/flutter (31134): Converting object to an encodable object failed: _LinkedHashMap len:3 I/flutter (31134): I/flutter (31134): #0 _JsonStringifier.writeObject (dart:convert/json.dart:688:7) I/flutter (31134): #1 _JsonStringifier.writeMap (dart:convert/json.dart:769:7) I/flutter (31134): #2 _JsonStringifier.writeJsonValue (dart:convert/json.dart:724:21) I/flutter (31134): #3 _JsonStringifier.writeObject (dart:convert/json.dart:679:9) I/flutter (31134): #4 _JsonStringStringifier.printOn (dart:convert/json.dart:877:17) I/flutter (31134): #5 _JsonStringStringifier.stringify (dart:convert/json.dart:862:5) I/flutter (31134): #6 JsonEncoder.convert (dart:convert/json.dart:262:30) I/flutter (31134): #7 JsonCodec.encode (dart:convert/json.dart:172:45) I/flutter (31134): #8 StorageImpl.flush (package:get_storage/src/storage/io.dart:34:37) I/flutter (31134): #9 GetStorage._flush (package:get_storage/src/storage_impl.dart:144:23) I/flutter (31134): #10 GetQueue._check (package:get/get_utils/src/queue/get_queue.dart:42:47) I/flutter (31134): #11 GetQueue.add (package:get/get_utils/src/queue/get_queue.dart:29:5) I/flutter (31134): #12 GetStorage._addToQueue (package:get_storage/src/storage_impl.dart:139:18) I/flutter (31134): #13 Microtask.exec. (package:get_storage/src/storage_impl.dart:174:17) I/flutter (31134): #14
    I/flutter (31134): ----------------------------------------------------

    print('---translateMap, $translateMap');
    
    GetStorageUtil.translateBox
                      .write(item.msg!.targetId!, translateMap);
    
    opened by lizhuoyuan 0
  • Flutter Get.Storage() not changing data while using Get.back()

    Flutter Get.Storage() not changing data while using Get.back()

    Get.back() does not change the data. It stores data while I write in GetStorage but only Get.to()/ Get.named() these changes the data of Get.Storage(). While try to Get.back() it is not changing the data. Is there any solution for this?

    opened by saminBee 0
  • HashSet support?

    HashSet support?

    Hi,

    I was attempting to write a HashSet<String> object to get_storage like so:

    final hSet = HashSet<String>();
    
    hSet.add("foo");
    hSet.add("bar");
    
    GetStorage().write("some_key", hSet);
    

    But this error would occur and prevent get_stroage from writing to the persistent storage but leaving it in RAM:

    [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Converting object to an encodable object failed: Instance of '_HashSet<String>'
    #0      _JsonStringifier.writeObject (dart:convert/json.dart:792:7)
    #1      _JsonStringifier.writeMap (dart:convert/json.dart:873:7)
    #2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:828:21)
    #3      _JsonStringifier.writeObject (dart:convert/json.dart:783:9)
    #4      _JsonStringStringifier.printOn (dart:convert/json.dart:981:17)
    #5      _JsonStringStringifier.stringify (dart:convert/json.dart:966:5)
    #6      JsonEncoder.convert (dart:convert/json.dart:345:30)
    #7      JsonCodec.encode (dart:convert/json.dart:231:45)
    ...
    

    Or should I use List<String> instead? But doing so would result in some O(N) access time in my other piece of code, which does not sound good...

    opened by LBYPatrick 0
  • Cache persist even after uninstalling the app and installing it again

    Cache persist even after uninstalling the app and installing it again

    I've noticed a strange problem, that cache isn't cleared after uninstalling the app and installing it again from playstore, even if I wipe the cache. I'm still debugging the problem, is this problem related to the phone, or it may be a bug in this package? Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.0.4, on Microsoft Windows [Version 10.0.19043.1826], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2) X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK [√] Android Studio (version 2020.3) [√] Connected device (3 available) [√] HTTP Host Availability

    Phone details: oneplus 7 pro android 11 GM1917

    Note: am working on android studio, no need to worry about flutter doctor issue regarding visual studio

    opened by AdelKanso 2
Owner
Jonny Borges
VP of Engineering from Iris Finance. Developer and Lawyer. Passionate about dart and productivity hacks.
Jonny Borges
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

HiveDB 3.4k Dec 30, 2022
Get or set persistent storage value based on MMKV framework.

mmkv_flutter Plugin that allow Flutter to read value from persistent storage or save value to persistent storage based on MMKV framework Getting Start

OpenFlutter 101 Jan 17, 2022
Lucifer is a fast, light-weight web framework in dart.

Lucifer Lightbringer Lucifer is a fast, light-weight web framework in dart. It's built on top of native HttpServer to provide a simple way to fulfill

Salman S 22 Jan 2, 2023
Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Vehement 8 Nov 26, 2022
Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting.

Bottlepay 43 Nov 2, 2022
Starter project for Flutter plugins willing to access native and synchronous rust code using FFI

Flutter Rust FFI Template This project is a Flutter Plugin template. It provides out-of-the box support for cross-compiling native Rust code for all a

Jør∂¡ 561 Dec 7, 2022
How to get the most value from Dart static analysis

This package is deprecated. Before it was deprecated, it was the way to get analysis options matching those used internally at Google. This was useful

Google 324 Nov 4, 2022
How to get the most value from Dart static analysis

This package is deprecated. Before it was deprecated, it was the way to get analysis options matching those used internally at Google. This was useful

Google 324 Nov 4, 2022
A Funtioning basic Clock UI APP with extra functionalities such as displaying thecurrent time location being used and checking time for other timezones simultaneosly.

clock_UI A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Anjola Favour Ayomikun 0 Dec 28, 2021
ValueNotifier, but outside Flutter and with some extra perks

Welcome to state_notifier~ This package is a recommended solution for managing state when using Provider or Riverpod. Long story short, instead of ext

Remi Rousselet 290 Dec 24, 2022
Add an extra tap region to button widgets

ExtraTapRegion A widget to add an extra tap region around the child widget. Example @override Widget build(BuildContext context) { return DeferredPo

Yusuke Otsuka 0 May 17, 2022
A flutter plugin to play Youtube Videos without API Key in range of Quality(144p, 240p,360p,480p,720p and 1080p).

Youtube Player Plugin This plugin is discontinued. Please use youtube_player_flutter which is an officially provided way of playing youtube videos, su

Sarbagya Dhaubanjar 120 Nov 13, 2022
Netflix app UI clone using bloc,Rest API and TMDB for API key

netflix_flutter project_using_bloc packages Used flutter_bloc json_serializable get_it dio A few resources to get you started if this is your first Fl

Pranav Pv 16 Nov 25, 2022
Fast and productive web framework provided by Dart

See https://github.com/angulardart for current updates on this project. Packages Source code Published Version angular angular_forms angular_router an

Angular Dart Open Source Packages 1.9k Dec 15, 2022
A degital diary with key feature of saving your thoughts with image

localstore A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

null 1 Nov 13, 2021
Behruz Hurramov 0 Dec 29, 2021
WIP: generate easy localization key code

Generates translation key code for the easy localization package. Support for json and yaml formats.You can see examples in the assets/ folder. Gettin

null 3 Oct 24, 2022
Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation with a minimum password strength required.

password_strength_checker Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation wit

Dario Varriale 6 Aug 8, 2023
Intel Corporation 238 Dec 24, 2022