doc method
Gets a DocumentReference instance that refers to the document at the specified path.
If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference.
If using withConverter, the path must not contain any slash.
Implementation
DocumentReference<T> doc([String? documentPath]) {
if (documentPath != null) {
_validateResourcePath('documentPath', documentPath);
} else {
documentPath = autoId();
}
final path = _resourcePath._append(documentPath);
if (!path.isDocument) {
throw ArgumentError.value(
documentPath,
'documentPath',
'Value for argument "documentPath" must point to a document, but was '
'"$documentPath". Your path does not contain an even number of components.',
);
}
if (!identical(_queryOptions.converter, _jsonConverter) &&
path.parent() != _resourcePath) {
throw ArgumentError.value(
documentPath,
'documentPath',
'Value for argument "documentPath" must not contain a slash (/) if '
'the parent collection has a custom converter.',
);
}
return DocumentReference<T>._(
firestore: firestore,
path: path,
converter: _queryOptions.converter,
);
}