xxxxxxxxxx
void main() {
Map<String, dynamic> myInfo = {
'name': 'Sabbir',
'age': 25,
'city': 'Narayanganj',
};
myInfo['country'] = 'Bangladesh';
print(myInfo);
}
// output
{name: Sabbir, age: 25, city: Narayanganj, country: Bangladesh}
xxxxxxxxxx
// Dart Map with method example
void main() {
Map<String, dynamic> person ={
'name': 'Sumon',
'age': '22',
'city':'Dhaka',
};
// add multiple element to the map..
person.addAll({'country': 'Bangladesh', 'gender': 'male'});
print(person);
// output:
//{name: Sumon, age: 22, city: Dhaka, country: Bangladesh, gender: male}
// remove speacific item from map..
person.remove('name');
print(person);
//output: {age: 22, city: Dhaka, country: Bangladesh, gender: male}
// remove all element from map..
person.clear();
print(person);
//output: {}
}
xxxxxxxxxx
// Dart Map with constructor
void main() {
Map<String, dynamic> student = new Map();
student['name'] = 'Abir';
student['Id'] = 'CSE19800459';
student['department'] = 'Computer Science Eng.';
//printing maps keys
print(student.keys);
// output: (name, Id, department)
//printing maps values
print(student.values);
// output: (Abir, CSE19800459, Computer Science Eng.)
}
xxxxxxxxxx
void main() {
var details = {'Usrname':'tom','Password':'pass@123'};
details['Uid'] = 'U1oo1';
print(details);
}
xxxxxxxxxx
void main() {
var details = new Map();
details['Usrname'] = 'admin';
details['Password'] = 'admin@123';
print(details);
}
// Output
// {Usrname: admin, Password: admin@123}
xxxxxxxxxx
void main() {
Map person={'name':'Bijay Poudel',"age":20};
//name and age are key and Bijay and 20 are value
print(person);
}
xxxxxxxxxx
void main() {
var details = {'Usrname':'tom','Password':'pass@123'};
details['Uid'] = 'U1oo1';
print(details);
}
xxxxxxxxxx
void main() {
var details = new Map();
details['Usrname'] = 'admin';
details['Password'] = 'admin@123';
print(details);
}
xxxxxxxxxx
Dart Map is an object that stores data in the form of a key-value pair.
xxxxxxxxxx
void main() {
var details = new Map();
details['Username'] = 'admin';
details['Password'] = 'admin@123';
print(details);
}