whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- double? width,
- double? height,
- double? size,
- @igFreezedJson BoxFit? fit,
- @igFreezedJson BorderRadius? borderRadius,
- @igFreezedJson BoxShape? shape,
- bool enableMemoryCache,
- String? heroTag,
- bool isSelected,
- @igFreezedJson Widget? errorWidget,
- @igFreezedJson VoidCallback? onTap,
- @igFreezedJson Color? color,
- bool clearMemoryCacheIfFailed,
- bool clearMemoryCacheWhenDispose,
- bool gaplessPlayback,
- @igFreezedJson BlendMode? colorBlendMode,
- FilterQuality filterQuality,
- double? scale,
- Map<
String, String> headers, - bool cache,
- int retries,
- @igFreezedJson Duration? timeLimit,
- @igFreezedJson Duration timeRetry,
- @igFreezedJson CancellationToken? cancelToken,
- String? cacheKey,
- bool printError,
- bool cacheRawData,
- String? imageCacheName,
- @igFreezedJson Duration? cacheMaxAge,
- int? cacheWidth,
- int? cacheHeight,
- double? compressionRatio,
- int? maxBytes,
- String? package,
- @igFreezedJson AssetBundle? bundle,
- @Doc(message: '自定义完成小部件') @igFreezedJson CustomCompletedWidget? customCompletedWidget,
- @igFreezedJson Widget? customLoadingWidget,
- @igFreezedJson InitEditorConfigHandler? initEditorConfigHandler,
- @igFreezedJson Key? extendedImageEditorKey,
- @igFreezedJson ExtendedImageMode? mode,
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( double? width, double? height, double? size, @igFreezedJson BoxFit? fit, @igFreezedJson BorderRadius? borderRadius, @igFreezedJson BoxShape? shape, bool enableMemoryCache, String? heroTag, bool isSelected, @igFreezedJson Widget? errorWidget, @igFreezedJson VoidCallback? onTap, @igFreezedJson Color? color, bool clearMemoryCacheIfFailed, bool clearMemoryCacheWhenDispose, bool gaplessPlayback, @igFreezedJson BlendMode? colorBlendMode, FilterQuality filterQuality, double? scale, Map<String, String> headers, bool cache, int retries, @igFreezedJson Duration? timeLimit, @igFreezedJson Duration timeRetry, @igFreezedJson CancellationToken? cancelToken, String? cacheKey, bool printError, bool cacheRawData, String? imageCacheName, @igFreezedJson Duration? cacheMaxAge, int? cacheWidth, int? cacheHeight, double? compressionRatio, int? maxBytes, String? package, @igFreezedJson AssetBundle? bundle, @Doc(message: '自定义完成小部件')@igFreezedJson CustomCompletedWidget? customCompletedWidget, @igFreezedJson Widget? customLoadingWidget, @igFreezedJson InitEditorConfigHandler? initEditorConfigHandler, @igFreezedJson Key? extendedImageEditorKey, @igFreezedJson ExtendedImageMode? mode)? $default,) {final _that = this;
switch (_that) {
case _ImageParams() when $default != null:
return $default(_that.width,_that.height,_that.size,_that.fit,_that.borderRadius,_that.shape,_that.enableMemoryCache,_that.heroTag,_that.isSelected,_that.errorWidget,_that.onTap,_that.color,_that.clearMemoryCacheIfFailed,_that.clearMemoryCacheWhenDispose,_that.gaplessPlayback,_that.colorBlendMode,_that.filterQuality,_that.scale,_that.headers,_that.cache,_that.retries,_that.timeLimit,_that.timeRetry,_that.cancelToken,_that.cacheKey,_that.printError,_that.cacheRawData,_that.imageCacheName,_that.cacheMaxAge,_that.cacheWidth,_that.cacheHeight,_that.compressionRatio,_that.maxBytes,_that.package,_that.bundle,_that.customCompletedWidget,_that.customLoadingWidget,_that.initEditorConfigHandler,_that.extendedImageEditorKey,_that.mode);case _:
return null;
}
}