create static method

BackgroundType create(
  1. Map<String, dynamic> json
)

Creates a new BackgroundType object. This method decides which BackgroundType subclass to use based on the type field.

Implementation

static BackgroundType create(Map<String, dynamic> json) {
  switch (json['type']) {
    case 'fill':
      return BackgroundTypeFill.fromJson(json);
    case 'wallpaper':
      return BackgroundTypeWallpaper.fromJson(json);
    case 'pattern':
      return BackgroundTypePattern.fromJson(json);
    case 'chat_theme':
      return BackgroundTypeChatTheme.fromJson(json);
    default:
      throw ArgumentError('Invalid background type');
  }
}