experimental_connectivity_web 0.2.0

  • Readme
  • Changelog
  • Installing
  • 71

experimental_connectivity_web #

A web implementation of connectivity. Currently this package uses an experimental API, with a fallback to dart:html, so not all features are available to all browsers.

Usage #

Import the package #

This package is a non-endorsed implementation of connectivity for the web platform, so you need to modify your pubspec.yaml to use it:

...
dependencies:
  ...
  connectivity: ^0.4.9
  experimental_connectivity_web: ^0.2.0
  ...
...

Example #

Find the example wiring in the Google sign-in example application.

Limitations on the web platform #

In order to retrieve information about the quality/speed of a browser's connection, the web implementation of the connectivity plugin uses the browser's NetworkInformation Web API, which as of this writing (February 2020) is still "experimental", and not available in all browsers:

Data on support for the netinfo feature across the major browsers from caniuse.com

On desktop browsers, this API only returns a very broad set of connectivity statuses (One of 'slow-2g', '2g', '3g', or '4g'), and may not provide an Stream of changes. Firefox still hasn't enabled this feature by default.

Fallback to navigator.onLine

For those browsers where the NetworkInformation Web API is not available, the plugin falls back to the NavigatorOnLine Web API, which is more broadly supported:

Data on support for the online-status feature across the major browsers from caniuse.com

The NavigatorOnLine API is provided by dart:html, and only supports a boolean connectivity status (either online or offline), with no network speed information. In those cases the plugin will return either wifi (when the browser is online) or none (when it's not).

Other than the approximate "downlink" speed, where available, and due to security and privacy concerns, no Web browser will provide any specific information about the actual network your users' device is connected to, like the SSID on a Wi-Fi, or the MAC address of their device.

Contributions and Testing #

Tests are a crucial to contributions to this package. All new contributions should be reasonably tested.

In order to run tests in this package, do:

cd test
flutter run -d chrome

All contributions to this package are welcome. Read the Contributing to Flutter Plugins guide to get started.

Issues and feedback #

Please file an issue to send feedback or report a bug.

Thank you!

0.2.0 #

  • Add fallback on dart:html for browsers where NetworkInformationAPI is not supported.

0.1.0 #

  • Initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  experimental_connectivity_web: ^0.2.0

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

We analyzed this package on May 24, 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

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and experimental_connectivity_web.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
connectivity_platform_interface ^1.0.3 1.0.6
flutter 0.0.0
flutter_web_plugins 0.0.0
js ^0.6.1+1 0.6.1+1
Transitive dependencies
collection 1.14.12
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
e2e ^0.2.4+3
flutter_driver
flutter_test
test any