maybeMap<TResult extends Object?> method
- @optionalTypeArgs
- TResult fill(
- BackgroundTypeFill value
- TResult wallpaper(
- BackgroundTypeWallpaper value
- TResult pattern(
- BackgroundTypePattern value
- TResult chatTheme(
- BackgroundTypeChatTheme value
- required TResult orElse(),
A variant of map that fallback to returning orElse.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(BackgroundTypeFill value)? fill,
TResult Function(BackgroundTypeWallpaper value)? wallpaper,
TResult Function(BackgroundTypePattern value)? pattern,
TResult Function(BackgroundTypeChatTheme value)? chatTheme,
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case BackgroundTypeFill() when fill != null:
return fill(_that);
case BackgroundTypeWallpaper() when wallpaper != null:
return wallpaper(_that);
case BackgroundTypePattern() when pattern != null:
return pattern(_that);
case BackgroundTypeChatTheme() when chatTheme != null:
return chatTheme(_that);
case _:
return orElse();
}
}