0

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.

1 Answers1

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