ConnectionChecker class abstract
Interface for checking network connectivity.
Implement this in your app controller or connectivity service. The repository uses this to determine whether to fetch from API or cache.
Example:
class AppController implements ConnectionChecker {
final _connectivity = Connectivity();
@override
bool get isConnected => _hasConnection;
bool _hasConnection = true;
Future<void> init() async {
_connectivity.onConnectivityChanged.listen((result) {
_hasConnection = result != ConnectivityResult.none;
});
}
}
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
Returns true if the device has network connectivity.
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