2

Checking out Flutter Web. Seems Firestore Flutter Web integration is not quite there yet. Tried to pass {merge: true} param:

webFirestore
    .collection("/users")
    .doc(uid)
    .set(map, {merge: true});

{merge: true} is underlined with red lines. Tried different formats, none working. Does anyone know how the syntax needs to look like?

This is what the firestore docs are saying:

/// An object to configure the [WriteBatch.set] behavior.
/// Pass [: {merge: true} :] to only replace the values specified in
/// the data argument. Fields omitted will remain untouched.
@anonymous
@JS()
abstract class SetOptions {
  /// Set to true to replace only the values from the new data.
  /// Fields omitted will remain untouched.
  external bool get merge;
  external set merge(bool v);
  external factory SetOptions({bool merge});
}
9
  • Try it without the brackets.
    – Benjamin
    Dec 15, 2019 at 13:11
  • Like that: .set(map, merge: true);? Not working says named parameter merge is not defined
    – Vlad
    Dec 15, 2019 at 13:13
  • Are you using this firebase package? The cloud_firestore package does not support Flutter for the web.
    – Benjamin
    Dec 15, 2019 at 13:19
  • I'm using 'package:firebase/firebase.dart' as WebFirebase; 'package:firebase/firestore.dart' as WebFirestore; - [this] (medium.com/multiverse-software/…) workaround
    – Vlad
    Dec 15, 2019 at 13:26
  • You mentioned that it's underlined with red lines when you used brackets, what's the error?
    – Benjamin
    Dec 15, 2019 at 13:35

2 Answers 2

16

Was having the same issue, I believe this works:

webFirestore
    .collection("/users")
    .doc(uid)
    .set(map, SetOptions(merge: true));
0
0

try this it will work

firestoreInstance.collection("users").doc(firebaseUser.uid).set(
  {
   "username" : "userX",
  },SetOptions(merge: true))

thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.