Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

flutter - How to add a list in a list to another list

I have a list called test3 and I want to add this list to another list test0. The problem is that I only want the "noequipment" "sublist" to be added to the test0.

I tried it with the following code:

var test0 = test0 + test3["noequipment"];

This is list test3:

var test3 = [
  {
    "noequipment": [
      {"name": "test0.1", "time": 10},
      {"name": "test0.2", "time": 10},
      {"name": "test0.3", "time": 10},
      {"name": "test0.4", "time": 10},
    ]
  },
  {
    "equipment1": [
      {"name": "test1.1", "time": 10},
      {"name": "test1.2", "time": 10},
      {"name": "test1.3", "time": 10},
      {"name": "test1.4", "time": 10},
    ]
  },
];
question from:https://stackoverflow.com/questions/65831543/how-to-add-a-list-in-a-list-to-another-list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Maybe you are looking for this answer

for (var i in test3[0]['noequipment']) {
  test0.add(i);
  print("===========>>${test0}");
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...