isConnected function Services

  1. @riverpod
bool isConnected(
  1. dynamic ref
)

A provider for the device's connectivity status.

This provider yields the value of the isConnectedStreamProvider as a boolean as opposed to a AsyncValue<bool>. If there is no value, it will default to true.

Implementation

@riverpod
bool isConnected(IsConnectedRef ref) {
  return ref.watch(isConnectedStreamProvider).asData?.value ?? true;
}