captured property

List captured

List of all arguments captured in real calls.

This list will include any captured default arguments and has no structure differentiating the arguments of one call from another. Given the following class:

class C {
  String methodWithPositionalArgs(int x, [int y]) => '';
  String methodWithTwoNamedArgs(int x, {int y, int z}) => '';
}

the following stub calls will result in the following captured arguments:

mock.methodWithPositionalArgs(1);
mock.methodWithPositionalArgs(2, 3);
var captured = verify(
    mock.methodWithPositionalArgs(captureAny, captureAny)).captured;
print(captured); // Prints "[1, null, 2, 3]"

mock.methodWithTwoNamedArgs(1, y: 42, z: 43);
mock.methodWithTwoNamedArgs(1, y: 44, z: 45);
var captured = verify(
    mock.methodWithTwoNamedArgs(any,
        y: captureAnyNamed('y'), z: captureAnyNamed('z'))).captured;
print(captured); // Prints "[42, 43, 44, 45]"

Named arguments are listed in the order they are captured in, not the order in which they were passed.

Implementation

List<dynamic> get captured => _captured;
  1. @Deprecated('captured should be considered final - assigning this field may be ' 'removed as early as Mockito 5.0.0')
void captured=(List captured)

Implementation

@Deprecated(
    'captured should be considered final - assigning this field may be '
    'removed as early as Mockito 5.0.0')
// ignore: unnecessary_getters_setters
set captured(List<dynamic> captured) => _captured = captured;