whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String condition,
    2. String merchant,
    3. Map merchantLogoOffset,
    4. String shipping,
    5. String price,
    6. String total,
    7. String link,
    )?
)

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 condition,  String merchant, @JsonKey(name: 'merchant_logo')  String merchantLogo, @JsonKey(name: 'merchant_logo_offset')  Map merchantLogoOffset,  String shipping,  String price,  String total,  String link)?  $default,) {final _that = this;
switch (_that) {
case _Merchant() when $default != null:
return $default(_that.condition,_that.merchant,_that.merchantLogo,_that.merchantLogoOffset,_that.shipping,_that.price,_that.total,_that.link);case _:
  return null;

}
}