createDocument method

Future<Document> createDocument(
  1. String path,
  2. String? documentId,
  3. Document document
)

Implementation

Future<Document> createDocument(
    String path, String? documentId, fs.Document document) async {
  var split = path.split('/');
  var parent = split.sublist(0, split.length - 1).join('/');
  var collectionId = split.last;

  var request = CreateDocumentRequest()
    ..parent = parent
    ..collectionId = collectionId
    ..documentId = documentId ?? ''
    ..document = document;

  var response =
      await _client.createDocument(request).catchError(_handleError);
  return Document(this, response);
}