I am Beginner in flutter, learning map concept. I am confusing map methods. How to delete a specific value from a map?
for example:
Map data = {
"studet1": {"name": "ajk", "age": "22", "place": "delhi"},
"studet2": {"name": "akmal", "age": "25", "place": "up"}
};
I want to delete the "name" from "student1".
2
Answers
data
is a nestedmap
, which means that it has anothermap
within the key ofstudent1
.You can use the
.remove
method to remove a key within a map:Prints:
If you want to remove only student1 name
Just use
data['student1'].remove('name');
Or if you want to remove all students name use the bleow method
The output will be