maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String? authority,
- String? serviceName,
- bool? multiMode,
- @JsonKey.new(name: 'idle_timeout') int? idleTimeout,
- @JsonKey.new(name: 'health_check_timeout') int? healthCheckTimeout,
- @JsonKey.new(name: 'permit_without_stream') bool? permitWithoutStream,
- @JsonKey.new(name: 'initial_windows_size') int? initialWindowsSize,
- @JsonKey.new(name: 'user_agent') String? userAgent,
- 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? authority,
String? serviceName,
bool? multiMode,
@JsonKey(name: 'idle_timeout') int? idleTimeout,
@JsonKey(name: 'health_check_timeout') int? healthCheckTimeout,
@JsonKey(name: 'permit_without_stream') bool? permitWithoutStream,
@JsonKey(name: 'initial_windows_size') int? initialWindowsSize,
@JsonKey(name: 'user_agent') String? userAgent)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _GRPCConfig() when $default != null:
return $default(
_that.authority,
_that.serviceName,
_that.multiMode,
_that.idleTimeout,
_that.healthCheckTimeout,
_that.permitWithoutStream,
_that.initialWindowsSize,
_that.userAgent);
case _:
return orElse();
}
}