What is the best way to store data from Firebase to SQLite or offline in flutter?

▼魔方 西西 提交于 2020-06-17 11:45:25

问题


In my app when user is offline, I want data to store in local db and then sync data with firebase.


回答1:


Both FireStore and Realtime Database have offline persistence.

Firestore :

Firestore.instance.settings(persistenceEnabled: true)

In the case of Firebase Realtime database, you don't need anything specific to set-up. Offline connectivity is automatic. So, the following line does the trick :

databaseReference.child(dbKey).set(data);


来源:https://stackoverflow.com/questions/61315478/what-is-the-best-way-to-store-data-from-firebase-to-sqlite-or-offline-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!