初始化:init
1 2 3
| import 'package:flutter_cache_kit/flutter_cache_kit.dart';
LocalStorage.init();
|
Flutter 类型数据保存和获取方法:save/get
1 2 3 4 5 6 7
| import 'package:flutter_cache_kit/flutter_cache_kit.dart';
LocalStorage.save('test_string', string);
String string = LocalStorage.get('test_string');
|
自定义的类的保存和获取方法:saveCustomBean\getCustomBean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| import 'package:flutter_cache_kit/flutter_cache_kit.dart';
TSCustomBean customBean = TSCustomBean( proxyId: '1001', proxyIp: '192.168.1.1', name: '代理', ); LocalStorage.saveCustomBean( 'test_custom', customBean, itemToJson: (TSCustomBean bItem) { return bItem.toJson(); }, );
TSCustomBean customBean = LocalStorage.getCustomBean( 'test_custom', fromJson: (bMap) { return TSCustomBean.fromJson(bMap); }, );
|
自定义的数组类的保存和获取方法:saveCustomBeans\getCustomBeans
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| import 'package:flutter_cache_kit/flutter_cache_kit.dart';
LocalStorage.saveCustomBeans( 'test_customBeans', customBeans, itemToJson: (TSCustomBean bItem) { return bItem.toJson(); }, );
List<TSCustomBean> customBeans = LocalStorage.getCustomBeans( 'test_customBeans', fromJson: (bMap) { return TSCustomBean.fromJson(bMap); }, );
|