wahyu
wahyu

Reputation: 2405

How to insert a new data inside an object in dart

I am trying to update data inside an object, here is the sample of object:

List myData = [
               {"data": "hello 1", "data 2": "hello 2"}
             ];

is it possible to add "data 3":"hello 3" inside myData[0] without creating a new object? so here is the the object that I want:

List myData = [
          {"data": "hello 1", "data 2": "hello 2","data 3":"hello 3"}
   ];

Upvotes: 0

Views: 129

Answers (1)

Amir MB
Amir MB

Reputation: 3418

You can easily add data to the map:

myData[0]["data 3"] = "hello 3";

Upvotes: 2

Related Questions