fromJson method

  1. @override
DateTime fromJson(
  1. Object timestamp
)

Implementation

@override
DateTime fromJson(Object timestamp) {
  if (timestamp is Timestamp) {
    return timestamp.toDate();
  } else if (timestamp is Map) {
    Map<Object?, Object?> timestampMap = timestamp;
    int seconds = timestampMap['_seconds'] as int;
    int nanoseconds = timestampMap['_nanoseconds'] as int;
    return DateTime.fromMicrosecondsSinceEpoch(seconds * 1000000 + nanoseconds ~/ 1000);
  }
  return DateTime.fromMillisecondsSinceEpoch(0);
}