DateTimeConverter class
A custom JsonConverter
for serializing and deserializing DateTime objects.
This converter handles the conversion of DateTime objects to and from JSON.
It provides a default value of DateTime.parse('2000-01-01 00:00')
when the
JSON input is null. This ensures that a non-null DateTime object is always returned
even if the input JSON is null.
This converter can be used with the json_annotation
package to facilitate JSON
serialization and deserialization for Dart objects that include DateTime properties.
Constructors
- DateTimeConverter()
-
Creates a new instance of DateTimeConverter.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fromJson(
DateTime? json) → DateTime - Converts the JSON value to a DateTime object.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
DateTime object) → DateTime? - Converts the DateTime object to a JSON value.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited