SmartTimestampConverter class
Smart timestamp converter that handles multiple formats and contexts.
This converter is the recommended choice for use with BaseFirestoreModel. It intelligently handles:
- Firestore Timestamp objects
- Cloud Functions Map format ({_seconds, _nanoseconds})
- Milliseconds since epoch (int)
- ISO 8601 strings
For serialization (toJson), it always returns milliseconds, and BaseFirestoreModel will handle conversion to FieldValue.serverTimestamp or Timestamp based on the context and field configuration.
Example:
@SmartTimestampConverter()
final DateTime? createdAt;
@SmartTimestampConverter()
final DateTime? updatedAt;
Constructors
- SmartTimestampConverter()
-
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(
dynamic data) → DateTime? -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
DateTime? dateTime) → dynamic -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited