maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. RunStepObjectObject object,
    3. int createdAt,
    4. String assistantId,
    5. String threadId,
    6. String runId,
    7. RunStepType type,
    8. RunStepStatus status,
    9. RunStepDetails stepDetails,
    10. RunStepLastError? lastError,
    11. int? expiredAt,
    12. int? cancelledAt,
    13. int? failedAt,
    14. int? completedAt,
    15. Map<String, dynamic>? metadata,
    16. RunStepCompletionUsage? usage,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  TResult Function(
          String id,
          RunStepObjectObject object,
          @JsonKey(name: 'created_at') int createdAt,
          @JsonKey(name: 'assistant_id') String assistantId,
          @JsonKey(name: 'thread_id') String threadId,
          @JsonKey(name: 'run_id') String runId,
          RunStepType type,
          RunStepStatus status,
          @JsonKey(name: 'step_details') RunStepDetails stepDetails,
          @JsonKey(name: 'last_error') RunStepLastError? lastError,
          @JsonKey(name: 'expired_at') int? expiredAt,
          @JsonKey(name: 'cancelled_at') int? cancelledAt,
          @JsonKey(name: 'failed_at') int? failedAt,
          @JsonKey(name: 'completed_at') int? completedAt,
          Map<String, dynamic>? metadata,
          RunStepCompletionUsage? usage)?
      $default, {
  required TResult orElse(),
}) {
  final _that = this;
  switch (_that) {
    case _RunStepObject() when $default != null:
      return $default(
          _that.id,
          _that.object,
          _that.createdAt,
          _that.assistantId,
          _that.threadId,
          _that.runId,
          _that.type,
          _that.status,
          _that.stepDetails,
          _that.lastError,
          _that.expiredAt,
          _that.cancelledAt,
          _that.failedAt,
          _that.completedAt,
          _that.metadata,
          _that.usage);
    case _:
      return orElse();
  }
}