isConnectedStream function Services

  1. @Riverpod(keepAlive: true)
Stream<bool> isConnectedStream(
  1. dynamic ref
)

A provider for a stream of booleans that represent the device's connectivity.

Implementation

@Riverpod(keepAlive: true)
Stream<bool> isConnectedStream(IsConnectedStreamRef ref) {
  return Connectivity()
      .onConnectivityChanged
      .map((result) => !result.contains(ConnectivityResult.none));
}