Map_Example_Dart

 import "dart:io";

void main()
{
var cars = {
"maruti" : 1,
"hyundai" : 2,
"toyota" : 3,
"tata" : 4,
"bmw" : 5,
"mercedes" : 6,
"skoda" : 7,
"renault" : 8,
"audi" : 9,
"kia" : 10,
"nissan" : 11,
"ford" : 12,
"mahindra" : 13,
"jaguar" : 14,
"honda" : 15,
"chevrolet" : 16,
"lamborghini" : 17,
"bentley" : 18,
"jeep" : 19,
"volvo" : 20,
};

print("$cars\n");

print("Enter the key : ");
var user = stdin.readLineSync();

if(cars.keys.contains(user))
{
print("\nAbove given key is Already Exist at Value ${cars[user]} in below Map\n");
print(cars);
}
else
{
cars["$user"] = 21;
print(cars);

print("Please Enter another key : ");
var otherKey = stdin.readLineSync();
if(cars.keys.contains(otherKey))
{
print("Key Already Exist");
}
else
{
cars["$otherKey"] = 22;
print(cars);
}
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter