Line data Source code
1 : // https://flutter.dev/docs/development/data-and-backend/json#serializing-json-inside-model-classes 2 : import 'package:json_annotation/json_annotation.dart'; 3 : part 'entrymodel.g.dart'; 4 : 5 : /// EntryModel refers to the generic class for entry result 6 : @JsonSerializable(createFactory: true) 7 : class EntryModel { 8 : String locale; 9 : String title; 10 : String url; 11 : String description; 12 : List categories; 13 : List tags; 14 : String uid; 15 : @JsonKey(name: 'created_by') 16 : String createdBy; 17 : @JsonKey(name: 'updated_by') 18 : String updatedBy; 19 : @JsonKey(name: 'created_at') 20 : String createdAt; 21 : @JsonKey(name: 'updated_at') 22 : String updatedAt; 23 : @JsonKey(name: '_version') 24 : int version; 25 2 : EntryModel( 26 : this.locale, 27 : this.title, 28 : this.url, 29 : this.description, 30 : this.categories, 31 : this.tags, 32 : this.uid, 33 : this.createdBy, 34 : this.updatedBy, 35 : this.createdAt, 36 : this.updatedAt, 37 : this.version); 38 2 : factory EntryModel.fromJson(Map<String, dynamic> json) => 39 2 : _$EntryModelFromJson(json); 40 0 : Map<String, dynamic> toJson() => _$EntryModelToJson(this); 41 : }