mgs_connectivity_check 1.1.0
mgs_connectivity_check: ^1.1.0 copied to clipboard
A customizable Flutter connectivity checker with internet validation and automatic no-internet dialog support.
mgs_connectivity_check
A Flutter connectivity utility that verifies real internet access and provides an optional customizable no-internet dialog with automatic monitoring.
Overview
mgs_connectivity_check helps Flutter applications:
Verify actual internet access (not just network type)
Listen to connectivity changes
Automatically show a configurable no-internet dialog
Open system network settings
Support Web and all major Flutter platforms
This package performs DNS-based validation (except on Web where platform limitations apply).
Features
Real internet connectivity check
Connectivity change listener
Automatic no-internet dialog
Built-in “Open Settings” button
Fully customizable dialog UI
Optional full dialog override
Web-safe implementation
Abstracted connection type enum
Installation
Add the dependency:
dependencies: mgs_connectivity_check: ^1.1.0
Then run:
flutter pub get
Usage
Import:
import 'package:mgs_connectivity_check/mgs_connectivity_check.dart';
Check Internet Manually bool connected = await MgsConnectivityCheck.isConnectedToInternet();
Listen and Automatically Show Dialog @override void initState() { super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) { MgsConnectivityCheck .listenChangeInInternetConnectivityWithDialog( context: context, ); }); }
@override void dispose() { MgsConnectivityCheck.dispose(); super.dispose(); }
Get Connection Type final types = await MgsConnectivityCheck.getConnectionTypes();
print(types);
Dialog Customization
You can customize the dialog using MgsDialogStyle:
MgsConnectivityCheck.listenChangeInInternetConnectivityWithDialog( context: context, dialogStyle: MgsDialogStyle( backgroundColor: Colors.black, buttonColor: Colors.blue, buttonText: "Retry", openSettingsButtonText: "Open Settings", ), );
Open System Settings
The dialog can include a button that opens wireless settings:
MgsDialogStyle( enableOpenSettingsButton: true, );
If the current settings type is unavailable, the system default settings page will open.
Full Dialog Override
You may completely replace the built-in UI:
MgsDialogStyle( customDialog: YourCustomWidget(), );
Platform Support Platform Supported Android Yes iOS Yes Web Yes* macOS Yes Windows Yes Linux Yes
- Web uses limited browser API support.
Important Notes
Network type does not guarantee internet access.
The package performs DNS validation (except on Web).
Always handle network requests with proper error handling.
License
MIT License