DatumConnectivityChecker class abstract

An abstract interface for checking network connectivity.

This allows the datum library to remain platform-agnostic. The user of the library is responsible for providing a concrete implementation.

Example Implementation for Flutter:

import 'package:connectivity_plus/connectivity_plus.dart';

class MyConnectivityChecker implements ConnectivityChecker {
  final _connectivity = Connectivity();

  @override
  Future<bool> get isConnected async =>
      !(await _connectivity.checkConnectivity()).contains(ConnectivityResult.none);

  @override
  Stream<bool> get onStatusChange => _connectivity.onConnectivityChanged
      .map((results) => !results.contains(ConnectivityResult.none));
}

Constructors

DatumConnectivityChecker()

Properties

hashCode int
The hash code for this object.
no setterinherited
isConnected Future<bool>
Checks if the device is connected to a network.
no setter
onStatusChange Stream<bool>
A stream that emits the connectivity status whenever it changes.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited