connection_notifier 0.0.1 copy "connection_notifier: ^0.0.1" to clipboard
connection_notifier: ^0.0.1 copied to clipboard

A Flutter package that notifies when no internet connection.

Connection Notifier #

A simple way to notify your user about the connection status.

Basic Usage: ConnectionNotifier

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ConnectionNotifier(    /// Wrap [MaterialApp] with [ConnectionNotifier], and that is it!
      child: MaterialApp(
        title: 'Connection Notifier Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MyHomePage(),
      ),
    );
  }
}

ConnectionNotifierToggler

If you want to toggle between some widgets automatically based on connection state.

ConnectionNotifierToggler(
        onConnectionStatusChanged: (connected) {
          /// that means it is still in the initialization phase.
          if (connected == null) return;
          print(connected);
        },
        connected: Center(
          key: UniqueKey(),
          child: const Text(
            'Connected',
            style: TextStyle(
              color: Colors.green,
              fontSize: 48,
            ),
          ),
        ),
        disconnected: Center(
          key: UniqueKey(),
          child: const Text(
            'Disconnected',
            style: TextStyle(
              color: Colors.red,
              fontSize: 48,
            ),
          ),
        ),
      );

Check Anywhere inside UI for internet connection

 ConnectionNotifierManager.isConnected(context); // you need to check if it is null (it will be null in initialization phase only).

Attribution #

This package depends on the following (Big Thanks):

flutter_bloc
oktoast
internet_connection_checker

License #

MIT License

111
likes
140
pub points
93%
popularity

Publisher

unverified uploader

A Flutter package that notifies when no internet connection.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bloc, flutter, flutter_bloc, internet_connection_checker, oktoast

More

Packages that depend on connection_notifier