Map is the base language for Dart

A collection of the form key value

var a = {'name': 'ducafecat'.'web': 'www.ducafecat.tech'};
Copy the code

loose

var a = new Map(a); a['name'] = 'ducafecat';
a['web'] = 'www.ducafecat.tech';
a[0] = 'abc';
Copy the code

Strongly typed

var b = new Map<int.String> (); b[0] = 'java';
b[1] = 'python';
Copy the code

Basic attributes

| | name that | | — – | — – | | isEmpty whether | null | | isNotEmpty | whether isn’t empty | | keys | key collection | | values | values set | | length | number | | entries | processing | data entry

print(a.isEmpty);
print(a.isNotEmpty);
print(a.keys);
print(a.values);
print(a.length);
print(a.entries);
Copy the code

Commonly used method

| | name that | | — – | — – | | addAll add | | | addEntries | from entrance to add | | either containsKey | press key queries | | containsValue | |. According to the value query Empty | in the | | | remove | delete a | | removeWhere | condition delete | | update | update a | | updateAll | | update according to conditions

addAll

b.addAll({'first': 'java'.'second': 'python'});
Copy the code

addEntries

b.addEntries(a.entries);
Copy the code

containsKey

print(a.containsKey('name'));
Copy the code

containsValue

print(a.containsValue('www.ducafecat.tech'));
Copy the code

clear

b.clear();
Copy the code

remove

A.r emove (" name ");Copy the code

removeWhere

A.removewhere ((key,val) => key == 'name');Copy the code

update

A.u pdate (' name ', (val) = > "ABC");Copy the code

updateAll

A.u pdateAll ((key, val) = > "- $val -");Copy the code

The operator

| | name that | | — – | — – | | [] value | | | | = | assignment []

print(a['name']);
a['name'] = 'abc';
Copy the code

PDF document sorting:

Dart Basic Language Learning – Part 1. PDF

Blog Source: Blog of rainy Night