Dart : Records

Dart : Records

ยท

1 min read

  • As a list ,set , map , record is also one type of the object in dart.

  • Where in other object we can store only one data type at one time , where in record we can save all four type of the data type in one object.

  • Like in record , I can save int , String, double and bool together in one object.

  • Here, I am providing Example of this to better understand.

  •   var record = (45 , a:true , "5.2" , "hello");
      print(record.a);  // true
      print(record); //(45, 5.2, hello, a: true)
      print(record.$2); //5.2
    
  • In this we can only define a name to field so we can use this name to print particular value , as I write in above example .

  • While , we can also use "$0" for the index value where 0 indicating index value.

ย