import 'package:json_annotation/json_annotation.dart'; import 'package:rhythm_box/services/sourced_track/enums.dart'; part 'source_map.g.dart'; @JsonSerializable() class SourceQualityMap { final String high; final String medium; final String low; const SourceQualityMap({ required this.high, required this.medium, required this.low, }); factory SourceQualityMap.fromJson(Map json) => _$SourceQualityMapFromJson(json); Map toJson() => _$SourceQualityMapToJson(this); operator [](SourceQualities key) { switch (key) { case SourceQualities.high: return high; case SourceQualities.medium: return medium; case SourceQualities.low: return low; } } } @JsonSerializable() class SourceMap { final SourceQualityMap? weba; final SourceQualityMap? m4a; const SourceMap({ this.weba, this.m4a, }); factory SourceMap.fromJson(Map json) => _$SourceMapFromJson(json); Map toJson() => _$SourceMapToJson(this); operator [](SourceCodecs key) { switch (key) { case SourceCodecs.weba: return weba; case SourceCodecs.m4a: return m4a; } } }