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.

3
  • Have you checked - pub.dev/packages/connectivity. This along with timer can solve your purpose. Commented Jul 9, 2020 at 3:59
  • I have seen the connectivity package. but what is this timmer? Commented Jul 9, 2020 at 4:08
  • Check if this helps - stackoverflow.com/a/62610924/5387880 Commented Jul 9, 2020 at 5:22

1 Answer 1

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.

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.