fconnectivity 0.3.0 copy "fconnectivity: ^0.3.0" to clipboard
fconnectivity: ^0.3.0 copied to clipboard

Connectivity package that contains useful utilities for checking if device is connected to the internet.

example/lib/main.dart

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

void main() => runApp(
      MaterialApp(
        home: Scaffold(
          body: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              InternetAccessConsumer(
                onInternetAccessGained: (BuildContext context) => debugPrint(
                  'Internet access gained (logged by InternetAccessConsumer)',
                ),
                onInternetAccessLost: (BuildContext context) => debugPrint(
                  'Internet access lost (logged by InternetAccessConsumer)',
                ),
                builder: ({
                  required BuildContext context,
                  required bool hasInternetAccess,
                }) =>
                    Text(
                  'This text widget rebuilds when internet access state changes. Current state of internet access: ${hasInternetAccess ? 'Available' : 'Not Available'}',
                  textAlign: TextAlign.center,
                ),
              ),
              const SizedBox(height: 20),
              InternetAccessListener(
                onInternetAccessGained: (BuildContext context) => debugPrint(
                  'Internet access gained (logged by InternetAccessListener)',
                ),
                onInternetAccessLost: (BuildContext context) => debugPrint(
                  'Internet access lost (logged by InternetAccessListener)',
                ),
                child: const Text(
                  'This text widget does not rebuild when internet access state changes.',
                  textAlign: TextAlign.center,
                ),
              ),
            ],
          ),
        ),
      ),
    );
3
likes
160
pub points
45%
popularity

Publisher

unverified uploader

Connectivity package that contains useful utilities for checking if device is connected to the internet.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

connectivity_plus, flutter, flutter_bloc, internet_connection_checker_plus

More

Packages that depend on fconnectivity