connectivity_listener 0.0.1+1 copy "connectivity_listener: ^0.0.1+1" to clipboard
connectivity_listener: ^0.0.1+1 copied to clipboard

A flutter package for both Android and iOS which provides a connection listener to determine if the app has an active internet connection

Connectivity Listener #

Connectivity Listener is a simple package that can be used to listen for changes in the connectivity.

Installation #

dependencies:
  flutter:
    sdk: flutter
  connectivity_listener: ^0.0.1

Usage #

import 'package:connectivity_listener/connectivity_listener.dart';
// The listener
final _connectionListener = ConnectionListener();

// Initialize the listener
@override
void initState() {
    super.initState();
    _connectionListener.init(
        onConnected: () => print("CONNECTED"),
        onReconnected: () => print("RECONNECTED"),
        onDisconnected: () => print("DISCONNECTED"),
    );
}

// Dispose the listener
@override
void dispose() {
    _connectionListener.dispose();
    super.dispose();
}

Methods #

Method Description
init() Creates the listener. Has 3 parameters: onConnected, onReconnected, onDisconnected. These can be used to perform a function when the specific connection status is detected.
dispose() Should be called on dipose. This cleans up the active listener and cancels all subscriptions

Demo #

5
likes
120
pub points
45%
popularity

Publisher

unverified uploader

A flutter package for both Android and iOS which provides a connection listener to determine if the app has an active internet connection

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

connectivity_plus, flutter

More

Packages that depend on connectivity_listener