0

I'm using flutter with firebase, how can I know if my device is connected to the internet or not when I wanna make a query to firestore? if my device is offline what will firestore return ?, I must detect the device connectivity situation, so I can emit a certain state in my app.

Ekhlass T
  • 63
  • 1
  • 10

1 Answers1

0

The Firestore SDK doesn't provide any way to know if the app is offline. The SDK was designed to work while offline. So, if you perform a query while offline, you will either get cached results, or the query will silently retry in the background.

If you want to test for connectivity, you will need try another method to do that. Or, you could use the Firestore REST API (not the Flutter SDK) and detect if the query failed due to network problems.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441