connectivity_watcher 1.0.3 copy "connectivity_watcher: ^1.0.3" to clipboard
connectivity_watcher: ^1.0.3 copied to clipboard

A Flutter package to check your internet connection with subsecond response times, even on mobile networks!.

connectivity_watcher #

Effortlessly adapt to changing network conditions with a single wrapper that seamlessly detects online/offline status. 🌐📲

Getting started #

First, add connectivity_watcher as a dependency in your pubspec.yaml file

connectivity_watcher: 1.0.3

Usage 🚀 #

What if i have to use a custom screen which my designer provided for no internet 😅!

The Custom method 😎✌️ : #

Wrap Your MaterialApp With ConnectionAwareApp and pass the connection style as custom and then pass your custom widget to offline widget as show thats it.

Widget build(BuildContext context) {
    return ConnectionAwareApp(
      connectivityStyle: NoConnectivityStyle.SNACKBAR,
      // connectivityStyle: NoConnectivityStyle.CUSTOM,
      offlineWidget: CustomNoInternetWrapper(
        builder: (context) {
          return CustomNoInternet();
        },
      ),
      // Place your custom no internet Widget
      builder: (context, connectionKey) {
        return MaterialApp(
            navigatorKey: connectionKey,
            debugShowCheckedModeBanner: false,
            title: 'Connectivity_Watcher',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: LoginDemo());
      },
    );
  }

Note: The package will automatically remove the custom widget if internet is back but in case its not removed you can use the follwing method to remove it

bool hasRemoved = await   ConnectivityWatcher.instance.hideNoInternet(currentContext: context);
if(hasRemoved){
 // your code after internet is back
    }
    else{
       print("No Internet");
    }

Preview #

custom

The lazy method: 😴💤 #

Wrap Your MaterialApp With ConnectionAwareApp and pass the connection style

  1. SnackBar Style
  Widget build(BuildContext context) {
    return ConnectionAwareApp(
      connectivityStyle: NoConnectivityStyle.SNACKBAR,
      builder: (context, connectionKey) {
        return MaterialApp(
            navigatorKey: connectionKey, // add this key to material app 
            debugShowCheckedModeBanner: false,
            title: 'Connectivity_Watcher',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: LoginDemo());
      },
    );
  }

Preview #

snackbar

  1. Alert
  Widget build(BuildContext context) {
    return ConnectionAwareApp(
     connectivityStyle: NoConnectivityStyle.ALERT,
      builder: (context, connectionKey) {
        return MaterialApp(
            navigatorKey: connectionKey, // add this key to material app 
            debugShowCheckedModeBanner: false,
            title: 'Connectivity_Watcher',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: LoginDemo());
      },
    );
  }

Preview #

alert

Check Internet Status #

bool hasInternet = await ConnectivityWatcher.instance.getConnectivityStatus(currentContext: context);

Contribution 🤝 #

Feel free to contribute and open pull requests. 🙌

Issues and Feedback 🐛 #

Feel free to post a feature requests or report a bug here.

28
likes
130
pub points
62%
popularity

Publisher

verified publisherthezerone.com

A Flutter package to check your internet connection with subsecond response times, even on mobile networks!.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, internet_connection_checker, provider

More

Packages that depend on connectivity_watcher