import 'package:json_annotation/json_annotation.dart'; part 'classes.g.dart'; @JsonSerializable() class SearchResponse { final int id; final String key; final String title; final String excerpt; final String description; const SearchResponse( this.id, this.key, this.title, this.excerpt, this.description); /// Connect the generated function to the `fromJson` /// factory. factory SearchResponse.fromJson(Map json) => _$SearchResponseFromJson(json); /// Connect the generated function to the `toJson` method. Map toJson() => _$SearchResponseToJson(this); } @JsonSerializable() class LicenseAttribution { final String url; final String title; const LicenseAttribution(this.url, this.title); factory LicenseAttribution.fromJson(Map json) => _$LicenseAttributionFromJson(json); /// Connect the generated function to the `toJson` method. Map toJson() => _$LicenseAttributionToJson(this); } @JsonSerializable() class RawPage { final int id; final String key; final String title; @JsonKey(fromJson: _editedFromJson, toJson: _editedToJson, name: "latest") final String edited; final String html; final LicenseAttribution license; const RawPage( this.id, this.key, this.title, this.edited, this.html, this.license); factory RawPage.fromJson(Map json) => _$RawPageFromJson(json); /// Connect the generated function to the `toJson` method. Map toJson() => _$RawPageToJson(this); static String _editedFromJson(Map json) => json["timestamp"]; static Map _editedToJson(String json) => {"timestamp": json}; }