emitAndPump<V> method

Future<void> emitAndPump<V>(
  1. ValueCell<V> cell,
  2. V? value, {
  3. Duration? duration,
})

Sets cell's value and pumps a single frame (or duration, if provided). Does not wait for settle.

Use when the test needs to observe an intermediate state — e.g., a loading spinner — before the widget settles, or when the receptor resolves on a timer that pumpAndSettle would not wait for.

Parameters:

  • cell: The Emitted Cell. Must be a ValueCell. See emitAndSettle for the assignment semantics.
  • value: The New Value. Assigned to cell.value before pumping. Subject to the same integrity-gate and evolve rules as emitAndSettle.
  • duration: Optional Frame Advance. When supplied, the helper calls WidgetTester.pump with this duration — advancing the fake clock by that amount, which fires any timers due within it. When omitted, a plain WidgetTester.pump advances a single frame.

Returns:

A Future that completes when the pumped frame has been rendered.

Example

final query = Cell.state<String>(initial: '');
await tester.pumpWidget(...);
await tester.emitAndPump(query.cell, 'dart');
expect(find.byType(Spinner), findsOneWidget);
await tester.pump(const Duration(seconds: 1));
expect(find.byType(ResultsList), findsOneWidget);

See Also:

Implementation

Future<void> emitAndPump<V>(
  ValueCell<V> cell,
  V? value, {
  Duration? duration,
}) {
  cell.value = value;
  return duration == null ? pump() : pump(duration);
}