'how to add new data to existing map in firebase flutter

here is the firebase document data

enter image description here

I want to add a new map value to the purchased-id. this is the current code

FirebaseFirestore.instance.collection('users').doc(userID).set({
  'purchased-id': {
    widget.head: widget.id,
  }
});               

but with this code the map value is replaced, how do I add another map value to the existing map

like this

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source