mgs_connectivity_check 1.1.6 copy "mgs_connectivity_check: ^1.1.6" to clipboard
mgs_connectivity_check: ^1.1.6 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 optionally displays a customizable no-internet dialog with automatic monitoring.

Overview #

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

mgs_connectivity_check performs real DNS validation (except on Web) to ensure true internet connectivity and provides automatic connectivity monitoring with a customizable dialog interface.

Features #

  1. Real internet connectivity validation

  2. Automatic connectivity change monitoring

  3. Built-in customizable no-internet dialog

  4. Optional Open Settings button

  5. Complete dialog UI override support

  6. Abstracted connection type enum

  7. Cross-platform support

Installation #

Add the dependency to your pubspec.yaml:

dependencies:
  mgs_connectivity_check: ^1.1.3

Then run:

flutter pub get

Usage #

Import the package:

import 'package:mgs_connectivity_check/mgs_connectivity_check.dart';

Check Internet Manually
bool isConnected =
    await MgsConnectivityCheck.isConnectedToInternet();

Listen & 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 #

Customize the built-in dialog using MgsDialogStyle:

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

Customizable Options #

Background color, Button color and text, Icon color and size, Border radius, Text styles, Enable/disable settings button, Full dialog override, Open System Settings

Enable built-in wireless settings access: #

MgsDialogStyle(
  enableOpenSettingsButton: true,
);

If wireless settings are unavailable on a platform, the system default settings screen will open automatically.

Full Dialog Override

Replace the entire dialog 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 used for connectivity verification (except on Web).

Always implement proper error handling for your network requests.

Call MgsConnectivityCheck.dispose() when monitoring is no longer needed.

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