internet_connectivity_checker 1.0.2 copy "internet_connectivity_checker: ^1.0.2" to clipboard
internet_connectivity_checker: ^1.0.2 copied to clipboard

The flutter package that helps you easily manage widgets dynamically based on the device's internet access.

example/lib/main.dart

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

void main() => runApp(const App());

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

  @override
  Widget build(BuildContext context) {
    TextStyle kTextStyle = Theme.of(context)
        .textTheme
        .headlineMedium!
        .copyWith(color: Colors.white);
    return MaterialApp(
      theme: ThemeData.dark(useMaterial3: true),
      home: Scaffold(
        backgroundColor: const Color(0XFF000F1D),
        appBar: AppBar(
          centerTitle: true,
          title: const Text("Internet Connectivity Checker"),
        ),
        body: Center(
          child: Container(
            width: 300,
            height: 300,
            margin: const EdgeInsets.all(20),
            child: ConnectivityBuilder(
              interval: const Duration(seconds: 5),
              builder: (ConnectivityStatus status) {
                if (status == ConnectivityStatus.online) {
                  return Container(
                    decoration: BoxDecoration(
                      color: Colors.green,
                      borderRadius: BorderRadius.circular(15),
                    ),
                    child: Center(child: Text("Online", style: kTextStyle)),
                  );
                } else if (status == ConnectivityStatus.offline) {
                  return Container(
                    decoration: BoxDecoration(
                      color: Colors.red,
                      borderRadius: BorderRadius.circular(15),
                    ),
                    child: Center(child: Text("Offline", style: kTextStyle)),
                  );
                } else {
                  // status == ConnectivityStatus.checking
                  return const Center(
                    child: SizedBox(
                      width: 25,
                      height: 25,
                      child: CircularProgressIndicator(strokeWidth: 2),
                    ),
                  );
                }
              },
            ),
          ),
        ),
      ),
    );
  }
}
36
likes
160
points
450
downloads

Publisher

verified publishermoustapha.dev

Weekly Downloads

The flutter package that helps you easily manage widgets dynamically based on the device's internet access.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on internet_connectivity_checker