NetworkStateNotifier class
A Riverpod-compatible StateNotifier-style class that manages
NetworkState and integrates with NetworkManager.
This class follows the StateNotifier contract (exposes state and
a stream) but does NOT import riverpod or state_notifier. It can
be used with:
StateNotifierProvider(Riverpod)- Any class that expects a
stategetter + stream
For full Riverpod integration, wrap this in your provider:
final myProvider =
StateNotifierProvider<NetworkStateNotifier, NetworkState>((ref) {
return NetworkStateNotifier(ref.watch(networkManagerProvider));
});
Constructors
- NetworkStateNotifier(NetworkManager _manager)
- Creates a NetworkStateNotifier bound to the given NetworkManager.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- manager → NetworkManager
-
The underlying NetworkManager.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state ↔ NetworkState
-
The current state.
getter/setter pair
-
stream
→ Stream<
NetworkState> -
Stream of state changes — compatible with Riverpod's
StateNotifier.stream.no setter
Methods
-
dispose(
) → Future< void> - Dispose resources.
-
execute<
T> (Future< T> requestFn(), {String? cacheKey, NetworkStrategy? strategy, Duration? cacheTtl}) → Future<T?> - Execute a network request and update state automatically.
-
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