The map.remove()
function in Dart removes a specific element (key-value pair) from the map.
- If the key is found in the map, the key-value pair is removed and the key is returned.
- If the key is not found in the map,
null
is returned.
The illustration below shows the visual representation of the map.remove()
function:
map_name.remove(key)
map_name
is the name of the queue.
The map.remove()
function requires a key
to remove that specific key-value pair from the map.
The Dart function map.remove()
removes a specific element (key-value pair) from a map.
The following code shows how to use the map.remove()
function in Dart:
import 'dart:convert';void main() {var map = new Map();map [1] = 'Tom';map [2] = 'Alsvin';map [3] = 'Eddie';//map containg key value pairs before removeprint("map elements before remove: ${map}");//map after remove 3rd elementprint("The value against 3rd element: ${map.remove(3)}");print("map elements after remove: ${map}");}