mirror of https://github.com/AMT-Cheif/drift.git
Fix deserialization of null datetime values
This commit is contained in:
parent
2e06ab763a
commit
a6505d691b
|
@ -50,8 +50,12 @@ class _DefaultValueSerializer extends ValueSerializer {
|
|||
@override
|
||||
T fromJson<T>(json) {
|
||||
if (T == DateTime) {
|
||||
if (json == null) {
|
||||
return null;
|
||||
} else {
|
||||
return DateTime.fromMillisecondsSinceEpoch(json as int) as T;
|
||||
}
|
||||
}
|
||||
|
||||
return json as T;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,12 @@ class CustomSerializer extends ValueSerializer {
|
|||
}
|
||||
|
||||
void main() {
|
||||
test('default serializer', () {
|
||||
final serializer = const ValueSerializer.defaults();
|
||||
expect(serializer.toJson<DateTime>(null), null);
|
||||
expect(serializer.fromJson<DateTime>(null), null);
|
||||
});
|
||||
|
||||
group('serialization', () {
|
||||
test('with defaults', () {
|
||||
expect(someTodoEntry.toJson(), equals(regularSerialized));
|
||||
|
|
Loading…
Reference in New Issue