import 'package:json_annotation/json_annotation.dart'; part 'searchepisodes.g.dart'; @JsonSerializable() class SearchEpisodes { @_ConvertE() final List episodes; @JsonKey(name: 'next_episode_pub_date') final int nextEpisodeDate; SearchEpisodes({this.episodes, this.nextEpisodeDate}); factory SearchEpisodes.fromJson(Map json) => _$SearchEpisodesFromJson(json); Map toJson() => _$SearchEpisodesToJson(this); } class _ConvertE implements JsonConverter { const _ConvertE(); @override E fromJson(Object json) { return OnlineEpisode.fromJson(json) as E; } @override Object toJson(E object) { return object; } } @JsonSerializable() class OnlineEpisode { final String title; @JsonKey(name: 'pub_date_ms') final int pubDate; @JsonKey(name: 'audio_length_sec') final int length; OnlineEpisode({this.title, this.pubDate, this.length}); factory OnlineEpisode.fromJson(Map json) => _$OnlineEpisodeFromJson(json); Map toJson() => _$OnlineEpisodeToJson(this); }