-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate converters into different files
- Loading branch information
Showing
8 changed files
with
63 additions
and
145 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
class DateTimeConverter extends JsonConverter<DateTime, String> { | ||
const DateTimeConverter(); | ||
|
||
@override | ||
DateTime fromJson(String json) { | ||
return DateTime.parse(json); | ||
} | ||
|
||
@override | ||
String toJson(DateTime object) { | ||
return object.toIso8601String(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:tuple/tuple.dart'; | ||
|
||
class TupleConverter extends JsonConverter<Tuple2<String, String>?, String?> { | ||
const TupleConverter(); | ||
|
||
@override | ||
Tuple2<String, String>? fromJson(String? json) { | ||
if (json == null) { | ||
return null; | ||
} | ||
return Tuple2<String, String>('', json); | ||
} | ||
|
||
@override | ||
String? toJson(Tuple2<String, String>? object) { | ||
if (object == null) { | ||
return null; | ||
} | ||
return object.item2; | ||
} | ||
} |
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
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
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
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
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
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