Stage.fromJson constructor

Stage.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory Stage.fromJson(Map<String, dynamic> json) {
  final type = json['type'];
  if (type == null) {
    throw FormatException('This is not a valid json for this barrage: ${jsonEncode(json)}');
  }
  switch (type) {
    case StageTypes.DOM:
      return DomStage.fromJson(json);
    default:
      throw UnsupportedError('Unknown Barrage Type: $type');
  }
}