add method

Future<DocumentReference> add(
  1. [String? name,
  2. Map<String, dynamic>? data]
)

Add a data document to this collection and returns a DocumentReference to this document.

If no name is provided, an auto-generated name is used. If no data is provided, this can be set later using the DocumentReference.setData() method.

Implementation

Future<DocumentReference> add([
  String? name,
  Map<String, dynamic>? data,
]) async {
  final newDocument = document(name);
  if (data != null) await newDocument.setData(data);
  return newDocument;
}