@@ -3,91 +3,6 @@ import 'package:codelessly_json_annotation/codelessly_json_annotation.dart';
33import 'node_json_converter.dart' ;
44import 'nodes/base_node.dart' ;
55
6- /// Converts [DateTime] ? to and from ISO 8601 [String] ?.
7- class DateTimeISO8601NullableConverter
8- extends JsonConverter <DateTime ?, String ?> {
9- /// Creates a new instance of [DateTimeISO8601NullableConverter] .
10- const DateTimeISO8601NullableConverter ();
11-
12- @override
13- DateTime ? fromJson (String ? json) => deserialize (json);
14-
15- @override
16- String ? toJson (DateTime ? object) => serialize (object);
17-
18- /// Serializes [DateTime] to [int] .
19- static String ? serialize (DateTime ? object) => object? .toIso8601String ();
20-
21- /// Deserializes [int] to [DateTime] .
22- static DateTime ? deserialize (String ? json) {
23- return json != null ? DateTime .parse (json) : null ;
24- }
25- }
26-
27- /// Converts [DateTime] ? to and from ISO 8601 [String]
28- class DateTimeISO8601Converter extends JsonConverter <DateTime , String > {
29- /// Creates a new instance of [DateTimeISO8601Converter] .
30- const DateTimeISO8601Converter ();
31-
32- @override
33- DateTime fromJson (String json) => deserialize (json);
34-
35- @override
36- String toJson (DateTime object) => serialize (object);
37-
38- /// Serializes [DateTime] to [int] .
39- static String serialize (DateTime object) => object.toIso8601String ();
40-
41- /// Deserializes [int] to [DateTime] .
42- static DateTime deserialize (String json) => DateTime .parse (json);
43- }
44-
45- /// Top level converter for serializing [DateTime] to [millisecondsSinceEpoch] .
46- class DateTimeConverter extends JsonConverter <DateTime , int ?> {
47- /// Creates a new instance of [DateTimeConverter] .
48- const DateTimeConverter ();
49-
50- @override
51- DateTime fromJson (int ? json) => deserialize (json);
52-
53- @override
54- int ? toJson (DateTime object) => serialize (object);
55-
56- /// Serializes [DateTime] to [int] .
57- static int ? serialize (DateTime object) =>
58- object.toUtc ().millisecondsSinceEpoch;
59-
60- /// Deserializes [int] to [DateTime] .
61- static DateTime deserialize (int ? json) {
62- return json != null
63- ? DateTime .fromMillisecondsSinceEpoch (json).toLocal ()
64- : DateTime .now ();
65- }
66- }
67-
68- /// Top level converter for serializing [DateTime] to [millisecondsSinceEpoch] .
69- class NullableDateTimeConverter extends JsonConverter <DateTime ?, int ?> {
70- /// Creates a new instance of [NullableDateTimeConverter] .
71- const NullableDateTimeConverter ();
72-
73- @override
74- DateTime ? fromJson (int ? json) => deserialize (json);
75-
76- @override
77- int ? toJson (DateTime ? object) => serialize (object);
78-
79- /// Serializes [DateTime] to [int] .
80- static int ? serialize (DateTime ? object) =>
81- object? .toUtc ().millisecondsSinceEpoch;
82-
83- /// Deserializes [int] to [DateTime] .
84- static DateTime ? deserialize (int ? json) {
85- return json != null
86- ? DateTime .fromMillisecondsSinceEpoch (json).toLocal ()
87- : null ;
88- }
89- }
90-
916/// Top level converter for serializing Nodes map to and from JSON.
927class CanvasesMapConverter extends JsonConverter <
938 Map <String , Map <String , BaseNode >>, Map <String , dynamic >> {
0 commit comments