connectivity_alert_widget 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

A package to simplify the task of showing users whether they are online or offline

Using #

The package has the ConnectivityAlertWidget, to use it only pass the widget to show when online and the widget to show when offline. The package abstract all of the hard work.

ConnectivityAlertWidget(
  onlineWidget: Icon(Icons.network_wifi, color: Colors.green, size: 280),
  offlineWidget: Icon(Icons.signal_wifi_off, color: Colors.red, size: 280),
  onConnectivityResult: (connectivity) => print(connectivity),
)

You can choose anything to be your onlineWidget or offlineWidget but it's recomended to use something that easily inform the user about her current online status.

Example

If you want to do anything when there's connectivity changes, you can implement onConnectivityResult, as it gives you a callback to be executed on every connectivity change.

[1.0.1] #

Exposing a callback to be executed in every connectivity change

[1.0.0+1] - Updating dependency #

Upgrading Connectivity dependency to ^0.4.8+1

[1.0.0] - First release #

The first release has the option to show the user if he's online or offline

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Example Connectivity'),
        centerTitle: true,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ConnectivityAlertWidget(
              onlineWidget:
                  Icon(Icons.network_wifi, color: Colors.green, size: 280),
              offlineWidget:
                  Icon(Icons.signal_wifi_off, color: Colors.red, size: 280),
              onConnectivityResult: (connectivity) => print(connectivity),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  connectivity_alert_widget: ^1.0.1

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_alert_widget/connectivity_alert_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
connectivity ^0.4.8+1 0.4.8+2
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
connectivity_macos 0.1.0+2
connectivity_platform_interface 1.0.3
meta 1.1.8
plugin_platform_interface 1.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test