In my app when user is offline, I want data to store in local db and then sync data with firebase.
Both FireStore and Realtime Database have offline persistence.
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 :