Map clear()
Map clear()
method removes all the key-value pairs from this Map.
Syntax
The syntax to remove all the entries from the Map map1
is
map1.clear();
The method returns void
.
ADVERTISEMENT
Examples
Remove all entries from the Map
In the following Dart Program, we take a Map map1
, and remove all the key-value pairs from this map1
using Map.clear()
method.
main.dart
void main() { var map1 = {'apple': 25, 'banana': 10}; map1.clear(); print(map1); }
Output
{}
Conclusion
In this Dart Tutorial, we learned how to remove all the entries from this Map, using Map.clear()
method.