Collections

 /// List

  /// Fixed List
/// Growable List
/// Set
/// Maps

void main()
{
/// Fixed List -> Implementation
//external factory List.filled(int length, E fill, {bool growable = false});

// List<int> larr = List<int>.filled(5,0);
// print(larr);

// List<int> larr = List.filled(4,2);
// larr[0] = 10;
// larr[1] = 20;
// larr[2] = 30;
// larr[3] = 40;
// print(larr[0]);

/// for-in loops
// for(int x in larr) {
// print(x);
// }

/// forEach loop
//larr.forEach((x) { print(x); },);

/// Normal Traditional for loop
// for(int i=0; i<larr.length; i++) {
// print(larr[i]); }

/// Growable List
// List<int> larr1 = [];
// larr1.add(10);
// larr1.add(20);
// larr1.add(30);
// larr1.add(40);
// larr1.add(50);
//print(larr1);

/// Updating the value in the List
//larr1[2] = 100;

/// Removing the value in the List
//larr1.remove(20); // Passing the value in the parameter which i want to remove
//larr1.removeAt(2); // Passing the index in the parameter which i want to remove
//larr1.clear(); // Completely removing the list using the clear function

/// Normal Traditional for loop
// for(int x=0; x<larr1.length; x++) {
// print(larr1[x]); }

/// for-in loop
// for(var x in larr1) {
// print(x); }

/// forEach loop
//larr1.forEach((x) { print(x); },);

// var myList = new List.filled(2,0);
// myList = [25, 63, 84];
// print(myList);

/// Set
//Set<int> sarr = Set(); // First way to define Set
//Set<int> sarr = Set.from([10,20,30],); // Second way to define Set
// sarr.add(11);
// sarr.add(22);
// sarr.add(33);
//print(sarr);

/// for in loop
// for(var i in sarr) {
// print(i); }

//print(sarr.contains(30)); //Checking the inclusion of element
//print(sarr.contains(22));

/// Maps
//Map<String,String> marr = Map(); // First way to define Map
Map<String,String> marr = { // Second way to define Map
"name" : "Vishal",
"city" : "Delhi"
};
marr["email"] = "vishal@gmail.com"; //Adding another data in Map
//print(marr);

/// for in loop
// for(String k in marr.keys) { //Getting all the Keys
// print(k); } // for in loop can give single value in one time

// for(String v in marr.values) { //Getting all the values
// print(v); }

//marr.remove("name"); //Removing any particular data from Map
//marr.clear(); //Completely removing the Map data using clear function
//print(marr.length); //Getting the length of the Map data
//print(marr.isEmpty); //Checking whether any data is available OR Not in Map
//print(marr.containsKey("name"));//To check whether any particular key is Exists OR Not in Map
//print(marr.containsValue("vishal@gmail.com"));//To check whether any particular Value is Exists OR Not in Map

/// forEach loop
// marr.forEach((key,value) { // forEach loop can give multiple values in one time
// print(key + " : " + value);
// },);
}

Comments

Popular posts from this blog

Pagination with Bloc Pattern in Flutter

ExpansionPanel with ExpansionPanelList with Complete Collapse Operation in Flutter

Pagination First Practical in Flutter