简体   繁体   中英

how to update a map value (of type table<String>) in Realtime db (Flutter)?

I'm trying to add a new value to the table choices (which is an element in a map<string,dynamic>). How can I do it? 在此处输入图像描述

There is no way to add an element to an array in the Firebase Realtime Database without first reading the entire array. So you'll have to:

  1. Read the current elements in the array
  2. Add the item to the array
  3. Write the entire array back to the database

This is one of the (many) reasons why Firebase recommends against using arrays for list-like structures and prefers using lists or maps. I recommend checking out Best Practices: Arrays in Firebase .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM