maybeMap<TResult extends Object?> method

TResult maybeMap<TResult extends Object?>({
  1. TResult wallpaper(
    1. BackgroundTypeWallpaper value
    )?,
  2. TResult pattern(
    1. BackgroundTypePattern value
    )?,
  3. TResult fill(
    1. BackgroundTypeFill value
    )?,
  4. TResult chatTheme(
    1. BackgroundTypeChatTheme value
    )?,
  5. required TResult orElse(),
})

Implementation

TResult maybeMap<TResult extends Object?>({
  TResult Function(BackgroundTypeWallpaper value)? wallpaper,
  TResult Function(BackgroundTypePattern value)? pattern,
  TResult Function(BackgroundTypeFill value)? fill,
  TResult Function(BackgroundTypeChatTheme value)? chatTheme,
  required TResult Function() orElse,
}) {
  switch (getConstructor()) {
    case BackgroundTypeWallpaper.constructor:
      if (wallpaper != null) {
        return wallpaper.call(this as BackgroundTypeWallpaper);
      }
      break;
    case BackgroundTypePattern.constructor:
      if (pattern != null) {
        return pattern.call(this as BackgroundTypePattern);
      }
      break;
    case BackgroundTypeFill.constructor:
      if (fill != null) {
        return fill.call(this as BackgroundTypeFill);
      }
      break;
    case BackgroundTypeChatTheme.constructor:
      if (chatTheme != null) {
        return chatTheme.call(this as BackgroundTypeChatTheme);
      }
      break;
  }
  return orElse.call();
}