doc method

  1. @override
DocumentReference<Map<String, dynamic>> doc(
  1. String path
)
override

Gets a DocumentReference for the specified Firestore path.

Implementation

@override
DocumentReference<Map<String, dynamic>> doc(String path) {
  // Remove the starting '/' if found, like the actual Firestore.
  if (path.startsWith('/')) {
    path = path.substring(1);
  }
  final segments = path.split('/');
  // The actual behavior of Firestore for an invalid number of segments
  // differs by platforms. This library imitates it with assert.
  // https://github.com/atn832/fake_cloud_firestore/issues/30
  assert(segments.length % 2 == 0,
      'Invalid document reference. Document references must have an even number of segments');
  final documentId = segments.last;
  return MockDocumentReference(
      this,
      path,
      documentId,
      getSubpath(_root, path),
      _docsData,
      _root,
      getSubpath(_snapshotStreamControllerRoot, path),
      null);
}