My example app works with adding/viewing data but data not visible in Firestore console - flutter

To understand Flutter & Firestore I have used the code from https://heartbeat.fritz.ai/using-firebases-cloud-firestore-in-flutter-79a79ec5303a. The app in a Pixel 2 simulator works as expected ie adding and displaying Tasks. I created a linked to my Firestore database but Tasks added are not being shown in Firestore Data. Any data I add directly in Firestore is not being shown in the app. The obvious conclusion is that I am looking at the wrong Firestore database. But it is from this database I copied the google-services.json and the database Usage relates to when I use the app. What approach can I use to debug this?
The google-services.json firebase_url (line 4) takes me to the firebase - Database - Realtime Database. But the Realtime database displays no data. I then select from the pull-down Firestore (but still no data displayed). I disabled the Realtime database. App works as expected. Displays Tasks stored from previous sessions and I can add new ones. Still can't see any stored data anywhere!!

I seemed to solve my problem by deleting the Pixel 2 emulator and creating a completely new one.

Related

If I use firestore offline to store the data for the chat app, do I still need sqlite, flutter

I wanna create a chatapp for my friend, and now remote serve I will use firestore and locally sqlite, but I realized it is default for firestore to save data offline, so my question is I have some data like message, or sending setting for the app, is it ok just to save them in firestore offline which seems automatically and no extra costs.
It depends on what you want or need.
If you want to use the offline persistance only for storing in case internet is not there at all. Firebase supports that out of the box. But you need to keep in mind to do you calls carefully. Because on a slow internet connection, if you tell the Firebase access to wait for the online behavior. It will not be using the local first and you might not be able to show the data. Check the question here
Also if you want to use the offline persistance from Firebase, be mindful that the data size has a default of 40 megabytes of limit. You might assign that by your self. You can check this link
BUT, if you want to have heavy data manipulations and have more control over your data SQLite is more suggested.
My opionion: I think Firebase Offline persistance would be enough for you, so go for it.

Data is not persisting for IndexedDB using Flutter and package Hive on web(chrome) browser

I'm using the flutter package Hive
The problem that I am encountering is that my website's data is not persisting for IndexedDB - web(chrome)
Has anyone else encountered inconsistency with data stored in IndexedDB for chrome?
Are there any additional steps outside of using the Hive package such as requesting persistent permission that I have to implement in order for the data to be stored?
Any feedback will be appreciated.
You don't even need to request the persistent storage permission to be able to store data. Persistent storage just makes it a bit more durable. So most likely, the data is never being written to IndexedDB in the first place. Could be an issue with your code or with a library you're using. Hard to say without seeing your code, especially since I've never used Hive.
This is a flutter project, using the hive package. It works fine on mobile devices, but when running the app in chrome the data gets lost after a refresh
Data after the initial load and initialisation
Empty boxes after refresh

Avoid fetching the same data from Firestore over and over again whenever the app starts

I am sorry, if it is a stupid question. I started to work with a Firestore db in a SwiftUI iOS App. Since I will be charged for every read/write/delete I try to avoid to read-in a snapshot with tons of documents (e.g. messages in a messenger app) every time the user starts the app.
I wondering what is the normal way to handle that? Do I have to write/save the messages locally into a sqlite or realm to fetch them at the next time from the internal db (on the Firestore side I create a query to read/load only documents that are newer than the last locally saved message)? Or does the Firestore (Firebase) has a built-in solution e.g. the cache?
I think you've already answered your question. You can save documents (messages) locally so you don't have to fetch them from Firestore every time (and only fetch the new ones). Firebase can cache data locally, but only temporarily. Saving the data using sqlite, realm, or even CoreData is a wise move.

flutter how to manually push data from firestore and save in sqflite

I have a firebase cloud database with a document that contains roughly 200 entries (Strings). These entries will only change every few weeks by a bit.
In order to save money (i.e. read and writes in firebase), I would like to push this list once in a while to my app and have it stored in the phone's sqflite database for further use in my app.
Is there a way to "manually" push that list (e.g. once a month) from the cloud database to my app and save it on the device's database? I searched for hours for a solution but nothing seems to fit.
Thanks

How to save data in flutter?

I am building an app like google's keep (notes taking app) using flutter. I can add notes but when I close the app, it resets to initial state. How can I save these notes so when I come back to app, I can read my previously added notes.
When you're saving in a list for example, and render, you're doing that on UI state which is temporary. If you want to store data to last even after the UI got refreshed, you have to use a database that will hold the data until you delete it.
If you just want to store some tiny data, for example light/dark mode preferences or login/logout sessions, you can use shared_preferences. For larger data, I used sqflite to store data in SQL database in system as a file which will be cleared after the app is memory-cleared or deleted. If you want to store the data in cloud, you can use firebase for that.
You have two options:
1) Save locally on device using database. Below are the db solutions.
Moor
Floor
2) Save on the server, you can use Firebase Cloud Firestore.