debugCheckInvalidValueType property

void Function<V>(V value)? debugCheckInvalidValueType
getter/setter pair

Checks the value of each Provider, while asserts are on: by default a Listenable or a Stream is a StateError, since its changes would rebuild nothing. Null checks none.

Implementation

static void Function<V>(V value)? debugCheckInvalidValueType = <V>(value) {
  if (value is Listenable || value is Stream<Object?>) {
    throw StateError(
      'Tried to use Provider with a subtype of Listenable/Stream ($V), '
      'which rebuilds nothing when it changes: provide it with a '
      'ListenableProvider, a ChangeNotifierProvider or a '
      'StreamProvider, or set Provider.debugCheckInvalidValueType to '
      'null',
    );
  }
};