diff --git a/README.md b/README.md index 9c5f4310..3fec7e70 100644 --- a/README.md +++ b/README.md @@ -584,12 +584,14 @@ The implementation and usage of the mentioned `DateTime` to `int` converter is d class DateTimeConverter extends TypeConverter { @override DateTime decode(int databaseValue) { - return DateTime.fromMillisecondsSinceEpoch(databaseValue); + return databaseValue == null + ? null + : DateTime.fromMillisecondsSinceEpoch(databaseValue); } @override int encode(DateTime value) { - return value.millisecondsSinceEpoch; + return value == null ? null : value.millisecondsSinceEpoch; } } ``` diff --git a/floor/README.md b/floor/README.md index 9c5f4310..3fec7e70 100644 --- a/floor/README.md +++ b/floor/README.md @@ -584,12 +584,14 @@ The implementation and usage of the mentioned `DateTime` to `int` converter is d class DateTimeConverter extends TypeConverter { @override DateTime decode(int databaseValue) { - return DateTime.fromMillisecondsSinceEpoch(databaseValue); + return databaseValue == null + ? null + : DateTime.fromMillisecondsSinceEpoch(databaseValue); } @override int encode(DateTime value) { - return value.millisecondsSinceEpoch; + return value == null ? null : value.millisecondsSinceEpoch; } } ```