connection_verify 1.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

connection_verify #

Package to verify the network connection status

Example #

if (await ConnectionVerify.connectionStatus()){
      print("I have network connection!");
      //Do your online stuff here
    } else {
      print("I don't have network connection!");
      //Do your offline stuff here

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

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

[0.0.1] - 2020-02-27. #

  • This package allows to knows how is the network connection status, for Android and iOS, 'true' if is connected, 'false' if is not.

[1.0.0] - 2020-02-27. #

  • Added example and README.

[1.0.1] - 2020-02-27. #

  • Doc added.

[1.0.2] - 2020-02-28. #

  • Removed unnecessary prints.

[1.0.3] - 2020-03-02. #

  • Code readability improvements.

[1.0.4] - 2020-04-02. #

  • Provided dart doc.


import 'package:flutter/material.dart';
import 'package:connection_verify/connection_verify.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
      home: MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void initState() {

  void _incrementCounter() async {
    // The network connection verification occurs every time this function is called.
    // It must occur inside an 'async' function, because this verification depends on the 'await' of the result
    // of the 'ping' test in '' site.

    if (await ConnectionVerify.connectionStatus()){
      print("I have network connection!");
      // Every time the ConnectionVerify.connectionStatus() returns 'true', there is network connection available.
      // Do your online stuff here
    } else {
      print("I don't have network connection!");
      // So, when the verification returns false, you are Offline, so offline treatments must be done here.
      // Do your offline stuff here
    setState(() {

  // The default 'counter app' build view
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          children: <Widget>[
              'You have pushed the button this many times:',
              style: Theme.of(context).textTheme.display1,
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),

Use this package as a library

1. Depend on it

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

  connection_verify: ^1.0.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:connection_verify/connection_verify.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 May 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies