Result<T> constructor

Result<T>({
  1. required bool isValid,
  2. required T value,
  3. List<Expectation>? expectations,
  4. Expectation? expectation,
})

Implementation

Result({
  required this.isValid,
  required this.value,
  List<Expectation>? expectations,
  Expectation? expectation,
})  : assert(
        isValid ||
            (!isValid && expectation != null ||
                (expectations != null && expectations.isNotEmpty)),
        'invalid -> provide an expectation or non-empty expectations list',
      ),
      expectations = List.unmodifiable(
        expectations ?? (expectation == null ? const <Expectation>[] : [expectation]),
      );