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.
Asked
Active
Viewed 784 times
0
-
Have you checked - https://pub.dev/packages/connectivity. This along with timer can solve your purpose. – Dash Jul 09 '20 at 03:59
-
I have seen the connectivity package. but what is this timmer? – Umakanth Pendyala Jul 09 '20 at 04:08
-
Check if this helps - https://stackoverflow.com/a/62610924/5387880 – Tanuj Jul 09 '20 at 05:22
1 Answers
1
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.
}

Abdul Malik
- 1,158
- 6
- 15