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

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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mgs_connectivity_check/mgs_connectivity_check.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

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

    // Start listening to internet changes
    MgsConnectivityCheck.listenChangeInInternetConnectivityWithDialog(
      context: context,

      // Only If developer wants customization use MgsDialogStyle and MgsBackOnlineStyle, no need if you are ok with default styling
      dialogStyle: const MgsDialogStyle(
        enableCloseAppButton: true,
        enableRetryButton: true,

        backOnlineStyle: MgsBackOnlineStyle(
          message: "Internet Connected Successfully!",
          backgroundColor: Colors.blue,
          duration: Duration(seconds: 3),
        ),
      ),
    );
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Connectivity Demo")),
      body: const Center(
        child: Text(
          "Turn Off Internet To See Dialog",
          style: TextStyle(fontSize: 18),
        ),
      ),
    );
  }
}
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