maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
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 field0)? str,
TResult Function(PlatformInt64 field0)? int,
TResult Function(double field0)? float,
TResult Function(bool field0)? bool,
TResult Function(List<String> field0)? listStr,
TResult Function(Int64List field0)? listInt,
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case PyArgument_Str() when str != null:
return str(_that.field0);
case PyArgument_Int() when int != null:
return int(_that.field0);
case PyArgument_Float() when float != null:
return float(_that.field0);
case PyArgument_Bool() when bool != null:
return bool(_that.field0);
case PyArgument_ListStr() when listStr != null:
return listStr(_that.field0);
case PyArgument_ListInt() when listInt != null:
return listInt(_that.field0);
case _:
return orElse();
}
}