set<T> method Null safety

void set<T>(
  1. DocumentReference<T> document,
  2. T data,
  3. [SetOptions? options]

Writes to the document referred to by document.

If the document does not yet exist, it will be created.

If SetOptions are provided, the data will be merged into an existing document instead of overwriting.


void set<T>(
  DocumentReference<T> document,
  T data, [
  SetOptions? options,
]) {
    document.firestore == _firestore,
    'the document provided is from a different Firestore instance',

  Map<String, dynamic> firestoreData;
  if (document is _JsonDocumentReference) {
    firestoreData = data as Map<String, dynamic>;
  } else {
    final withConverterDoc = document as _WithConverterDocumentReference<T>;
    firestoreData = withConverterDoc._toFirestore(data, options);

  return _delegate.set(