I am trying to add functionality to my app where it waits on the load screen till the internet connection is available. Is there any way I can achieve this functionality.
-
Have you checked - pub.dev/packages/connectivity. This along with timer can solve your purpose.Dash– Dash2020-07-09 03:59:19 +00:00Commented Jul 9, 2020 at 3:59
-
I have seen the connectivity package. but what is this timmer?Umakanth Pendyala– Umakanth Pendyala2020-07-09 04:08:39 +00:00Commented Jul 9, 2020 at 4:08
-
Check if this helps - stackoverflow.com/a/62610924/5387880Tanuj– Tanuj2020-07-09 05:22:33 +00:00Commented Jul 9, 2020 at 5:22
Add a comment
|
1 Answer
You can use the Flutter Favorite package called connectivity
This package has a method where you can check if
- A user has an internet connection or not
- Whether the user is using mobile data or Wifi
import 'package:connectivity/connectivity.dart';
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none) {
// I am not connected to any network.
} else if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
}