flutter_network_connectivity 0.0.6 copy "flutter_network_connectivity: ^0.0.6" to clipboard
flutter_network_connectivity: ^0.0.6 copied to clipboard

A Flutter Plugin to check for live network connectivity status. Plugin uses NetworkCapabilities for Android and NetworkMonitor for iOS.

Flutter Network Connectivity #

Pub

A flutter plugin to check for Internet Availability as a stream based on network connectivity status, periodic interval or on call.

Usage #

First, add flutter_network_connectivity as a dependency in your pubspec.yaml file.

dependencies:
  flutter_network_connectivity: ^0.0.6
copied to clipboard

Don't forget to flutter pub get.

Then import:

import 'package:flutter_network_connectivity/flutter_network_connectivity.dart';
copied to clipboard

Now you can create FlutterNetworkConnectivity object and use its methods

FlutterNetworkConnectivity flutterNetworkConnectivity =
    FlutterNetworkConnectivity(
	  isContinousLookUp: true,  // optional, false if you cont want continous lookup
	  lookUpDuration: const Duration(seconds: 5),  // optional, to override default lookup duration
	  lookUpUrl: 'example.com',  // optional, to override default lookup url
	);
copied to clipboard

To Check for Stream of Network Connectivity Status #

_flutterNetworkConnectivity.getInternetAvailabilityStream().listen((isInternetAvailable) {
  // do something
});
copied to clipboard

Then Register Availability Listener after setting up Stream Listerer

await _flutterNetworkConnectivity.registerAvailabilityListener();
copied to clipboard

Unregister on dispose

await _flutterNetworkConnectivity.unregisterAvailabilityListener();
copied to clipboard

To Check for Internet Availability on Call #

bool _isNetworkConnectedOnCall = await
    _flutterNetworkConnectivity.isInternetConnectionAvailable();
copied to clipboard

Examples #

Simple usage example can be found in the example folder.

Android

Uses permission

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
copied to clipboard

Minimum SDK Version 16

iOS

Uses NetworkMonitor, minimum required version 12.0

Demo

Screenshot

About #

This plugin uses NetworkCapabilities for Android and NetworkMonitor for iOS to check for network connectivity status.

Contributing? #

You're always welcome. See Contributing Guidelines. You can also take a look at Status Tracker to know more information about current or pending features/issues.

41
likes
160
points
909
downloads

Publisher

verified publisherlivelifedev.com

Weekly Downloads

2024.09.18 - 2025.04.02

A Flutter Plugin to check for live network connectivity status. Plugin uses NetworkCapabilities for Android and NetworkMonitor for iOS.

Repository (GitHub)
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_network_connectivity