Skip to main content

internet_status 1.0.0 copy "internet_status: ^1.0.0" to clipboard
internet_status: ^1.0.0 copied to clipboard

Checks whether the device really has internet access (DNS, socket and HTTP), streams the status, and shows an animated offline banner.

example/example.dart

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

void main() => runApp(const MaterialApp(home: StatusPage()));

/// Shows whether the device really has internet access, and why not when it
/// does not.
class StatusPage extends StatelessWidget {
  const StatusPage({super.key});

  @override
  Widget build(BuildContext context) {
    final checker = InternetConnectionChecker();
    return Scaffold(
      appBar: AppBar(title: const Text('internet_status')),
      body: Center(
        child: StreamBuilder<InternetResult>(
          stream: checker.onInternetConnectivityChanged,
          builder: (context, snapshot) {
            final result = snapshot.data;
            if (result == null) return const CircularProgressIndicator();
            return Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Icon(result.hasInternetAccess ? Icons.wifi : Icons.wifi_off, size: 48),
                Text(
                  result.hasInternetAccess
                      ? 'Online (${result.connectionType?.name ?? 'unknown'})'
                      : 'Offline: ${result.failureReason ?? 'a check failed'}',
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}
4
likes
160
points
32
downloads

Documentation

API reference

Publisher

verified publisherkenresoft.com

Weekly Downloads

Checks whether the device really has internet access (DNS, socket and HTTP), streams the status, and shows an animated offline banner.

Repository (GitHub)
View/report issues

Topics

#connectivity #network #internet #offline #banner

License

BSD-3-Clause (license)

Dependencies

connectivity_plus, flutter, rxdart

More

Packages that depend on internet_status