when<TResult extends Object?> method
TResult
when<TResult extends Object?>(
- TResult $default(
- double? width,
- double? height,
- double? size,
- BoxFit? fit,
- BorderRadius? borderRadius,
- BoxShape? shape,
- bool enableMemoryCache,
- String? heroTag,
- bool isSelected,
- Widget? errorWidget,
- VoidCallback? onTap,
- Color? color,
- bool clearMemoryCacheIfFailed,
- bool clearMemoryCacheWhenDispose,
- bool gaplessPlayback,
- BlendMode? colorBlendMode,
- FilterQuality filterQuality,
- double? scale,
- Map<
String, String> headers, - bool cache,
- int retries,
- Duration? timeLimit,
- Duration timeRetry,
- CancellationToken? cancelToken,
- String? cacheKey,
- bool printError,
- bool cacheRawData,
- String? imageCacheName,
- Duration? cacheMaxAge,
- int? cacheWidth,
- int? cacheHeight,
- double? compressionRatio,
- int? maxBytes,
- String? package,
- AssetBundle? bundle,
- CustomCompletedWidget? customCompletedWidget,
- Widget? customLoadingWidget,
- InitEditorConfigHandler? initEditorConfigHandler,
- Key? extendedImageEditorKey,
- ExtendedImageMode? mode,
A switch
-like method, using callbacks.
As opposed to map
, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs
TResult when<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():
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);
}
}