Search packages, repositories and app categories

GitHub repositorypraveen-gm/flutter_network_connectivity

flutter_network_connectivity

A Flutter plugin to check internet connectivity status on Android and iOS

flutter_network_connectivity project cover
Stars
6
Forks
1
Last push (UTC)
Nov 16, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

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

Don't forget to flutter pub get.

Then import:

import 'package:flutter_network_connectivity/flutter_network_connectivity.dart';

Now you can create FlutterNetworkConnectivity object and use its methods

FlutterNetworkConnectivity flutterNetworkConnectivity =
    FlutterNetworkConnectivity(
	  isContinousLookUp: true,  // optional, false if you don't want continous lookup
	  lookUpDuration: const Duration(seconds: 5),  // optional, to override default lookup duration
	  lookUpUrl: 'example.com',  // optional, to override default lookup url
	);
To Check for Stream of Network Connectivity Status
_flutterNetworkConnectivity.getInternetAvailabilityStream().listen((isInternetAvailable) {
  // do something
});

Then Register Availability Listener after setting up Stream Listerer

await _flutterNetworkConnectivity.registerAvailabilityListener();

Unregister on dispose

await _flutterNetworkConnectivity.unregisterAvailabilityListener();
To Check for Internet Availability on Call
bool _isNetworkConnectedOnCall = await
    _flutterNetworkConnectivity.isInternetConnectionAvailable();
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" />

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.

Praveen G GitHub avatar
GitHub author

Praveen G ↗

Full Stack Android & Flutter Developer.

Bengaluru, India
LanguagesDartKotlinSwiftRubyObjective-C

Categories

Packages published by this repository

Dependencies used

Dependency list 4 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}
  • lintsDevelopment^1.0.1
  • flutter_lintsDevelopment^1.0.4

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗