testNotifier<T> function

List<T> testNotifier<T>(
  1. StateNotifier<T> notifier,
  2. void action(
    1. StateNotifier<T>
    )
)

Runs a test on a StateNotifier and returns the list of emitted states.

Implementation

List<T> testNotifier<T>(
    StateNotifier<T> notifier, void Function(StateNotifier<T>) action) {
  final states = <T>[];
  final remove = notifier.addListener((s) => states.add(s));
  action(notifier);
  remove();
  return states;
}