maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String id,
- RunStepObjectObject object,
- int createdAt,
- String assistantId,
- String threadId,
- String runId,
- RunStepType type,
- RunStepStatus status,
- RunStepDetails stepDetails,
- RunStepLastError? lastError,
- int? expiredAt,
- int? cancelledAt,
- int? failedAt,
- int? completedAt,
- Map<
String, dynamic> ? metadata, - RunStepCompletionUsage? usage,
- 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();
}
}