Home > Net >  How to create an object like JavaScript in dart flutter and how to access statedata
How to create an object like JavaScript in dart flutter and how to access statedata

Time:07-16

  var statedata = {
     "name":"sajib",
     "name2":"sajib saha",
  };

i am create and object like javascript in dart file in flutter . but i can not get access of it ? how can i get call name or name2 to get the value . in javascript i can get statedata.name but its not working here please help me ?

CodePudding user response:

The data type you're looking at is called a Map. To access a key, you specify the key name within brackets. For example:

var statedata = {
     "name":"sajib",
     "name2":"sajib saha",
  };
  print(statedata["name2"]);

Prints:

sajib saha
  • Related