ConnectivityController class
The public-facing controller — the only type consumers interact with directly.
What it does:
- Wraps ConnectivityMonitorService in a typed ConnectivityState stream.
- Caches results on each emission.
- Fires registered callbacks (onConnectionLost, onConnectionRestored, etc.).
- Exposes
BehaviorSubjectso new subscribers get current state immediately. - Handles the initial cache read for immediate UI on app launch.
Constructors
- ConnectivityController({required ConnectivityMonitorService monitorService, required ConnectivityCache cache})
Properties
- currentResult → ConnectivityResultModel?
-
Current result, or null if checking.
no setter
- currentState → ConnectivityState
-
Current state — always available synchronously after initialization.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isOnline → bool
-
Whether internet is currently available.
no setter
-
isOnlineStream
→ Stream<
bool> -
Convenience stream — only emits on online/offline flips.
no setter
-
qualityStream
→ Stream<
ConnectionQuality> -
Convenience stream — only emits when ConnectionQuality tier changes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stateStream
→ Stream<
ConnectivityState> -
Stream of ConnectivityState. Replays latest value to new subscribers.
no setter
Methods
-
addConnectionLostListener(
void callback(ConnectivityResultModel result)) → void - Register a callback fired when internet access is lost.
-
addConnectionRestoredListener(
void callback(ConnectivityResultModel result)) → void - Register a callback fired when internet access is restored.
-
addQualityChangedListener(
void callback(ConnectionQuality prev, ConnectionQuality next)) → void - Register a callback fired when ConnectionQuality tier changes.
-
addStateChangedListener(
void callback(ConnectivityState state)) → void - Register a callback fired on every state change.
-
dispose(
) → Future< void> -
forceCheck(
) → Future< ConnectivityState> - Force an immediate probe outside the normal schedule.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeConnectionLostListener(
void callback(ConnectivityResultModel result)) → void -
removeConnectionRestoredListener(
void callback(ConnectivityResultModel result)) → void -
removeQualityChangedListener(
void callback(ConnectionQuality prev, ConnectionQuality next)) → void -
removeStateChangedListener(
void callback(ConnectivityState state)) → void -
start(
) → Future< void> - Called by SmartConnectivityMonitor.initialize.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited