connectivity_watcher 1.0.1
connectivity_watcher: ^1.0.1 copied to clipboard
Discover network connectivity changes throught the app with your own custom no internet widget.
connectivity_watcher #
Description #
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.1
Usage 🚀 #
The lazy method: 😴💤 #
Wrap Your MaterialApp With ConnectionAwareApp and pass the connection style
- 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 #
- 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 #
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());
},
);
}
Preview #
Check Internet Status #
context.read<ConnectivityController>().isInternetBack(internetStatus: (status){
// Your Code
});
Contribution 🤝 #
Feel free to contribute and open pull requests. 🙌
Issues and Feedback 🐛 #
Feel free to post a feature requests or report a bug here.