This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
class UTCDateTimeConverter implements JsonConverter<DateTime, String> { | |
const UTCDateTimeConverter(); | |
@override | |
DateTime fromJson(String dateTime) { | |
return DateTime.parse(dateTime).toLocal(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factory SearchRequest.fromJson(Map<String, dynamic> json) => _$SearchRequestFromJson(json); | |
Map<String, dynamic> toJson() => _$SearchRequestToJson(this); | |
SearchRequest clone() { | |
final String jsonString = json.encode(this); | |
final jsonResponse = json.decode(jsonString); | |
return SearchRequest.fromJson(jsonResponse as Map<String, dynamic>); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GENERATED CODE - DO NOT MODIFY BY HAND | |
part of 'publication_document.dart'; | |
// ************************************************************************** | |
// JsonSerializableGenerator | |
// ************************************************************************** | |
PublicationDocument _$PublicationDocumentFromJson(Map<String, dynamic> json) { | |
return PublicationDocument( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
import 'package:my_app/shared/helpers/custom_datetime.dart'; | |
part 'publication_document.g.dart'; | |
@JsonSerializable() | |
@CustomDateTimeConverter() | |
class PublicationDocument { | |
final int id; | |
final int publicationId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
class CustomDateTimeConverter implements JsonConverter<DateTime, String> { | |
const CustomDateTimeConverter(); | |
@override | |
DateTime fromJson(String json) { | |
if (json.contains(".")) { | |
json = json.substring(0, json.length - 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
part 'publication_document.g.dart'; | |
@JsonSerializable() | |
class PublicationDocument { | |
final int id; | |
final int publicationId; | |
final DateTime publicationDate; |