Created
January 29, 2022 12:00
-
-
Save chaudharydeepanshu/9de2632cd625c1a0cf7e7af1ae0f133a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:connectivity_plus/connectivity_plus.dart'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/services.dart'; | |
// Platform messages are asynchronous, so we initialize in an async method. | |
Future<ConnectivityResult?> initConnectivity( | |
{required Connectivity connectivity}) async { | |
// Platform messages may fail, so we use a try/catch PlatformException. | |
try { | |
return await connectivity.checkConnectivity(); | |
} on PlatformException catch (e) { | |
debugPrint(e.toString()); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment