Flutter知识点:数据存储之SharedPreferences

306 阅读1分钟
原文链接: www.jianshu.com

SharedPreferences轻量级存储类,以键值对的形式保存设置,属性和数据。

在Flutter平台我们使用shared_preferences库来同时支持Android 和iOS。

使用介绍

1.首选需要在pubspec.yaml 导入库


image.png

2.dart类中导入库


image.png

3.支持类型


image.png

4.增删改查

增: image.png 删: image.png 改: image.png 查: image.png

举例:


image.png

学习过程中的代码都放在github上了:github.com/zhujian1989…