AsyncNotifier<T> constructor

AsyncNotifier<T>({
  1. T? data,
  2. Object? error,
  3. StackTrace stackTrace = StackTrace.empty,
  4. ConnectionState state = ConnectionState.none,
  5. bool? cancelOnError,
})

Creates an AsyncNotifier instance with an initial value of type T.

The AsyncNotifier is designed to work with asynchronous operations that also produce data of type T.

Example:

final notifier = AsyncNotifier<List<Todo>>();

Implementation

AsyncNotifier({
  T? data,
  Object? error,
  StackTrace stackTrace = StackTrace.empty,
  ConnectionState state = ConnectionState.none,
  this.cancelOnError,
})  : assert(data == null || error == null),
      super(
        error != null
            ? AsyncSnapshot.withError(state, error, stackTrace)
            : data is T
                ? AsyncSnapshot.withData(state, data)
                : AsyncSnapshot<T>.nothing().inState(state),
      );