whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- 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,
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<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,) {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 null;
}
}