Home > Blockchain >  How can I store a data contains "." inside firestore inside a map field in flutter?
How can I store a data contains "." inside firestore inside a map field in flutter?

Time:11-23

When I add an email address to the map field vote data, Due to "." inside email address, it is creating a sub map with email.

How can I overcome this??

//Code Below

await FirebaseFirestore.instance
        .collection('polls')
        .doc(pollId)
        .update({"voteData.$currentUser": option});

Here currentUser = "[email protected]"

enter image description here

I tried this code too

await FirebaseFirestore.instance
        .collection('polls')
        .doc(pollId)
        .update({"voteData.${currentUser.replaceAll(".", "\\.")}": option});

but output is

enter image description here

CodePudding user response:

You have to escape the .

Try this,

await FirebaseFirestore.instance
        .collection('polls')
        .doc(pollId)
        .update({"voteData.${currentUser.replaceAll(".","\\.")}": option});
  • Related