DocumentReference<T extends dynamic>.fromJson constructor
DocumentReference<T extends dynamic>.fromJson (
- FirebaseFirestore firestore,
- Map<
String, Object?> json, { - FirestoreDataConverter<
T> ? converter,
Creates the reference toJson wrote, for firestore.
Implementation
factory DocumentReference.fromJson(
FirebaseFirestore firestore,
Map<String, Object?> json, {
FirestoreDataConverter<T>? converter,
}) {
final Object? referencePath = json['referencePath'];
if (json['type'] != jsonType || referencePath is! String) {
throw ArgumentError.value(
json,
'json',
'Not a JSON representation of a DocumentReference',
);
}
final ResourcePath path = ResourcePath.fromString(referencePath);
if (path.length == 0) {
throw ArgumentError.value(
json,
'json',
'The referencePath must be a document path',
);
}
return DocumentReference<T>.forPath(path, firestore, converter);
}