connectivity_widget 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 90

connectivity_widget #

A widget that shows the user if the phone is connected to the internet or not

This is accomplished not only by verifying the status of the mobile network and/or wifi, but also by pinging a remote server and verifying its response.


Using the ConnectivityWidget #

The ConnectivityWidget uses a builder function that provides you a isOnline flag to build different screens for offline or online mode.

        builder: (context, isOnline) => Center(
          child: Column(
            children: <Widget>[
              Text("${isOnline ? 'Online' : 'Offline'}", style: TextStyle(fontSize: 30, color: isOnline ? :,),
              SizedBox(height: 20,),
                'Number of times we connected to the internet:',
                style: Theme.of(context).textTheme.display1,

It also provides both a onlineCallback and a offlineCallback that are called when the phone changes the connection state to online and offline, respectively.

        onlineCallback: _incrementCounter,
        builder: //...,

If there is a need to change the default offline banner, a Widget can be provided to the offlineBanner parameter. Additionally, its visibility can be enabled or disabled by using the showOfflineBanner parameter.

Changing the server to ping and the response verification #

By default, the Connectivity Widget checks if there is a connection to If you want to check the availability of a custom endpoint, you can set a new endpoint to ping and a callback to verify the response.

ConnectivityUtils.instance.setCallback((response) => response.contains("This is a test!"));

Using ConnectivityUtils to Listen to Network Changes #

This library also provides access to the ConnectivityUtils class in which you can verify the status of the network.

Stream<bool> ConnectivityUtils.instance.isPhoneConnectedStream // gets the current status of the network
Future<bool> ConnectivityUtils.instance.isPhoneConnected() // future that determines network status


  • Change implementation from connectivity to simple_connectivity so that location-aware Info-plist strings are no longer required


  • Fix Dio dependency still present in repo
  • Change example


  • Update example
  • Remove Dio from dependencies


  • Banner is invisible when there is no connection
  • Fixed issue of banner not showing when starting the app in offline mode


  • Update RxDart Version


  • Initial Release


example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  connectivity_widget: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:connectivity_widget/connectivity_widget.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/src/connectivity_bloc.dart. (-1 points)

Analysis of lib/src/connectivity_bloc.dart reported 2 hints:

line 13 col 7: Close instances of dart.core.Sink.

line 20 col 7: Close instances of dart.core.Sink.

Fix lib/src/connectivity_util.dart. (-0.50 points)

Analysis of lib/src/connectivity_util.dart reported 1 hint:

line 2 col 8: Unused import: 'dart:io'.

Format lib/connectivity_widget.dart.

Run flutter format to format lib/connectivity_widget.dart.

Format lib/src/connectivity_widget.dart.

Run flutter format to format lib/src/connectivity_widget.dart.

Format lib/src/event.dart.

Run flutter format to format lib/src/event.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (rxdart).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
rxdart ^0.22.3 0.22.6 0.23.1
simple_connectivity ^0.1.0 0.1.0
stream_disposable ^0.1.0 0.1.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies