Timestamp.fromJson constructor
Builds a timestamp from a JSON map created by toJson.
Throws an ArgumentError if json does not have that shape or the value
is outside the supported range.
Implementation
factory Timestamp.fromJson(Map<String, Object?> json) {
final Object? seconds = json['seconds'];
final Object? nanoseconds = json['nanoseconds'];
if (json['type'] != jsonType || seconds is! int || nanoseconds is! int) {
throw ArgumentError.value(
json,
'json',
'Not a JSON representation of a Timestamp',
);
}
_validateRange(seconds, nanoseconds);
return Timestamp(seconds, nanoseconds);
}