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 : @JsonSerializable(createFactory: true) 6 : class EntryModel { 7 : String locale; 8 : String title; 9 : String url; 10 : String description; 11 : List categories; 12 : List tags; 13 : String uid; 14 : @JsonKey(name: 'created_by') 15 : String createdBy; 16 : @JsonKey(name: 'updated_by') 17 : String updatedBy; 18 : @JsonKey(name: 'created_at') 19 : String createdAt; 20 : @JsonKey(name: 'updated_at') 21 : String updatedAt; 22 : @JsonKey(name: '_version') 23 : int version; 24 1 : EntryModel( 25 : this.locale, 26 : this.title, 27 : this.url, 28 : this.description, 29 : this.categories, 30 : this.tags, 31 : this.uid, 32 : this.createdBy, 33 : this.updatedBy, 34 : this.createdAt, 35 : this.updatedAt, 36 : this.version); 37 1 : factory EntryModel.fromJson(Map<String, dynamic> json) => 38 1 : _$EntryModelFromJson(json); 39 0 : Map<String, dynamic> toJson() => _$EntryModelToJson(this); 40 : }