Flutter-数据持久化

1:flutter_secure_storage 4.1.0

A Flutter plugin to store data in secure storage:

  • Keychain is used for iOS

  • AES encryption is used for Android. AES secret key is encrypted with RSA and RSA key is stored in KeyStore

  • libsecret is used for Linux.

2:shared_preferences 2.0.5 比较常用

Wraps platform-specific persistent storage for simple data (NSUserDefaults on iOS and macOS, SharedPreferences on Android, etc.). Data may be persisted to disk asynchronously, and there is no guarantee that writes will be persisted to disk after returning, so this plugin must not be used for storing critical data.

为简单的数据包装平台特定的持久存储(NSUserDefaults在iOS和macOS, SharedPreferences在Android,等等)。数据可能是异步持久化到磁盘上的,并且不能保证写操作在返回后也会持久化到磁盘上,所以这个插件不能用于存储关键数据。

3:sqflite GitHub 本地数据首选

1: 三方sqflite使用

直接使用数据库语句,建表,查询,插入,更新,删除。需要自封装。但是最可靠。

sqflite使用case

PS: 最好将SQL模块使用单例模式抽象出来, 数据库的openDataBase 最好在启动时调用,表的创建也在你那里处理。

SQLite参考文档

Sql 语句 insert 不能插入重复的 主键的数据。

Sql 语句 select where

'SELECT * FROM tableName WHEREkey IN ($whereInStr)’

whereInStr:是一个String““AValue”,”BValue"”是指 id 的值们,他可能是 int 类型 也可能是 String 类型.

PS:table的名字,比较特殊不可带有“.” 或者 空格。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容