mgs_connectivity_check 1.1.5 copy "mgs_connectivity_check: ^1.1.5" to clipboard
mgs_connectivity_check: ^1.1.5 copied to clipboard

A customizable Flutter connectivity checker with internet validation and automatic no-internet dialog support.

mgs_connectivity_check #

A production-ready Flutter connectivity utility that verifies real internet access and provides an optional customizable no-internet dialog with automatic monitoring.

pub version pub points


Overview #

Most connectivity packages only detect network type (WiFi, Mobile, etc.). They do not verify actual internet access.

This package goes further by:

  • Performing real DNS validation
  • Automatically monitoring connectivity changes
  • Providing a ready-to-use customizable dialog
  • Allowing full UI override when needed
  • Supporting Web safely

Features #

  • Real internet connectivity verification
  • Automatic connectivity monitoring
  • Built-in no-internet dialog
  • Optional Open Settings button
  • Fully customizable dialog styling
  • Full dialog override support
  • Abstracted connection type enum
  • Cross-platform support

Installation #

Add the dependency:

dependencies:
  mgs_connectivity_check: ^1.1.0

Run:

flutter pub get

Quick Start #

Import #

import 'package:mgs_connectivity_check/mgs_connectivity_check.dart';

Check Internet Manually #

bool isConnected = await MgsConnectivityCheck.isConnectedToInternet();

Automatically Monitor & Show Dialog #

@override
void initState() {
  super.initState();

  WidgetsBinding.instance.addPostFrameCallback((_) {
    MgsConnectivityCheck.listenChangeInInternetConnectivityWithDialog(
      context: context,
    );
  });
}

@override
void dispose() {
  MgsConnectivityCheck.dispose();
  super.dispose();
}

Get Current Connection Type #

final types = await MgsConnectivityCheck.getConnectionTypes();

print(types);

Dialog Customization #

You can modify styling using MgsDialogStyle.

MgsConnectivityCheck.listenChangeInInternetConnectivityWithDialog(
  context: context,
  dialogStyle: MgsDialogStyle(
    backgroundColor: Colors.black,
    buttonColor: Colors.blue,
    buttonText: "Retry",
    enableOpenSettingsButton: true,
    openSettingsButtonText: "Open Settings",
  ),
);

Available Customizations #

  • Background color
  • Button color
  • Button text
  • Border radius
  • Icon & icon size
  • Text styles
  • Enable/disable settings button
  • Full custom dialog override

Open System Settings #

Enable the built-in system settings button:

MgsDialogStyle(
  enableOpenSettingsButton: true,
);

If wireless settings are unavailable, the system default settings screen will open.

Full Dialog Override #

Replace the entire UI:

MgsDialogStyle(
  customDialog: YourCustomWidget(),
);

Platform Support #

Platform Supported
Android Yes
iOS Yes
Web* Yes
macOS Yes
Windows Yes
Linux Yes

*Web uses limited browser connectivity APIs.


Important Notes #

  • Network type does not guarantee internet access.
  • DNS validation is performed (except on Web).
  • Always implement error handling in your API calls.
  • Call MgsConnectivityCheck.dispose() in dispose().

Contributing #

Pull requests and suggestions are welcome.


License #

MIT License

4
likes
0
points
429
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter connectivity checker with internet validation and automatic no-internet dialog support.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

app_settings, connectivity_plus, flutter

More

Packages that depend on mgs_connectivity_check