parent property

  1. @override
DocumentReferencePlatform? get parent

For subcollections, parent returns the containing DocumentReferencePlatform.

For root collections, null is returned.

Implementation

@override
DocumentReferencePlatform? get parent {
  final segments = path.split('/');
  // A root collection has one segment and no parent document; a subcollection
  // is addressed by dropping its own segment.
  if (segments.length < 2) return null;
  return FfiDocumentReference(
    ffiFirestore,
    segments.sublist(0, segments.length - 1).join('/'),
  );
}