mapOrNull<TResult extends Object?> method
TResult?
mapOrNull<TResult extends Object?>({
- TResult? android(
- AndroidPlatform value
- TResult? ios(
- IosPlatform value
- TResult? macos(
- MacosPlatform value
- TResult? web(
- WebPlatform value
- TResult? linux(
- LinuxPlatform value
- TResult? windows(
- WindowsPlatform value
- TResult? fuchsia(
- FuchsiaPlatform value
A variant of map that fallback to returning null.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( AndroidPlatform value)? android,TResult? Function( IosPlatform value)? ios,TResult? Function( MacosPlatform value)? macos,TResult? Function( WebPlatform value)? web,TResult? Function( LinuxPlatform value)? linux,TResult? Function( WindowsPlatform value)? windows,TResult? Function( FuchsiaPlatform value)? fuchsia,}){
final _that = this;
switch (_that) {
case AndroidPlatform() when android != null:
return android(_that);case IosPlatform() when ios != null:
return ios(_that);case MacosPlatform() when macos != null:
return macos(_that);case WebPlatform() when web != null:
return web(_that);case LinuxPlatform() when linux != null:
return linux(_that);case WindowsPlatform() when windows != null:
return windows(_that);case FuchsiaPlatform() when fuchsia != null:
return fuchsia(_that);case _:
return null;
}
}