maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default()?, {
- 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, String? checkoutUrl, CartCost? cost, int? totalQuantity, List<CartDiscountAllocation?>? discountAllocations, List<CartDiscountCode?>? discountCodes, String? createdAt, List<Attribute?>? attributes, CartBuyerIdentity? buyerIdentity, String? note, String? updatedAt, @JsonKey(fromJson: JsonHelper.lines) List<Line> lines)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Cart() when $default != null:
return $default(_that.id,_that.checkoutUrl,_that.cost,_that.totalQuantity,_that.discountAllocations,_that.discountCodes,_that.createdAt,_that.attributes,_that.buyerIdentity,_that.note,_that.updatedAt,_that.lines);case _:
return orElse();
}
}