thenReturn method

void thenReturn (
  1. T expected
)

Store a canned response for this method stub.

Note: expected cannot be a Future or Stream, due to Zone considerations. To return a Future or Stream from a method stub, use thenAnswer.

Implementation

void thenReturn(T expected) {
  if (expected is Future) {
    throw ArgumentError('`thenReturn` should not be used to return a Future. '
        'Instead, use `thenAnswer((_) => future)`.');
  }
  if (expected is Stream) {
    throw ArgumentError('`thenReturn` should not be used to return a Stream. '
        'Instead, use `thenAnswer((_) => stream)`.');
  }
  return _completeWhen((_) => expected);
}