shared_store 0.0.1 copy "shared_store: ^0.0.1" to clipboard
shared_store: ^0.0.1 copied to clipboard

Native storage solution based on MMKV.

shared_store #

Native storage solution based on MMKV.

Example #

iOS

Android

Usage #

一,Flutter端 #

1.添加依赖:

dependencies:
  flutter:
    sdk: flutter

  shared_store: ^0.01

2.启用SharedStore前,导入shared_store_plugin.dart对其进行初始化:

import 'package:shared_store/shared_store_plugin.dart';
SharedStorePlugin.initMMKV();

3.根据是否需要添加除内置默认的defaultMMKV外的可选的MMKV实例:

    String customMMKVId = "testPlugin";
    SharedStorePlugin.addMMKV(customMMKVId);

4.在需要存储数据时:

    const bool testBool = true;
    const int testInt = 123456;
    const double testDouble = 3.1415926;
    const String testString = 'testStringValue';
    String? boolResult = await SharedStorePlugin.storeBool('testBool', testBool);
    String? doubleResult = await SharedStorePlugin.storeDouble('testDouble', testDouble);
    String? intResult = await SharedStorePlugin.storeInt('testInt', testInt);
    String? stringResult = await SharedStorePlugin.storeString('testString', testString);

5.在需要读取数据时:

    bool? readBool = await SharedStorePlugin.readBool('testBool');
    int? readInt = await SharedStorePlugin.readInt('testInt');
    double? readDouble = await SharedStorePlugin.readDouble('testDouble');
    String? readString = await SharedStorePlugin.readString('testString');
1
likes
130
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

Native storage solution based on MMKV.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on shared_store