maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String title,
    2. String id,
    3. bool availableForSale,
    4. String createdAt,
    5. List<ProductVariant> productVariants,
    6. String productType,
    7. List<String> tags,
    8. List<ShopifyImage> images,
    9. List<Option> options,
    10. String vendor,
    11. List<ProductMedia> media,
    12. List<Metafield> metafields,
    13. List<AssociatedCollections>? collectionList,
    14. String? cursor,
    15. String? onlineStoreUrl,
    16. String? description,
    17. String? descriptionHtml,
    18. String? handle,
    )?, {
  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 title,  String id,  bool availableForSale,  String createdAt,  List<ProductVariant> productVariants,  String productType,  List<String> tags,  List<ShopifyImage> images,  List<Option> options,  String vendor,  List<ProductMedia> media,  List<Metafield> metafields,  List<AssociatedCollections>? collectionList,  String? cursor,  String? onlineStoreUrl,  String? description,  String? descriptionHtml,  String? handle)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Product() when $default != null:
return $default(_that.title,_that.id,_that.availableForSale,_that.createdAt,_that.productVariants,_that.productType,_that.tags,_that.images,_that.options,_that.vendor,_that.media,_that.metafields,_that.collectionList,_that.cursor,_that.onlineStoreUrl,_that.description,_that.descriptionHtml,_that.handle);case _:
  return orElse();

}
}