natrium_wallet_flutter
natrium_wallet_flutter copied to clipboard
Change the method used in order to detect the device's network connection
I think you should consider changing the way you detect the device's internet connection. As I understood reading by your code, the application does not detect when the device has lost network connection until it makes another service call. Then, it starts calling the service every 3 seconds in a loop until the connection is back. This behavior could affect the performance of the app, as it will constantly be trying to make new network calls until the user has a network connection again. Besides, it is a good practice to notify the user when the device has lost internet connection, instead of only showing a loading page. Therefore, I recommend you use the connectivity plugin to detect the connection status via a stream. With this new plugin, you should be able to detect when the user has lost/gained an internet connection and update the UI accordingly. Likewise, the app will be able to pause network and service calls until a stable connection returns. The pull request I made shows how to make use of this plugin, by showing a “No Network Connection” message in the home page whenever the device has lost internet connection Please take into account that the translation updates did not work for me, nor did I have the chance of testing the code on an iOS device. Hope this can come in handy to you guys. Warm regards, Sergio Yepes
That's a good point and we talked about it before but never implemented it.
We made an animation for kalium https://rive.app/a/yekta/files/flare/kalium-no-internet-animation/preview for this specific purpose.
I'll take a look at this pull later this weekend