我可以调用 list.add() 在末尾添加,但没有方便的方法将条目添加到特定索引,同时增加列表。
最佳答案
Dart 2
var idx = 3;
list.insert(idx, 'foo');
取决于你是想插入单个项目还是一堆项目
- https://api.dartlang.org/stable/2.1.0/dart-core/List/insert.html
- https://api.dartlang.org/stable/2.1.0/dart-core/List/insertAll.html
所有可用方法 https://api.dartlang.org/stable/2.1.0/dart-core/List-class.html#instance-methods
关于dart - 如何将条目添加到列表中的特定索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54684906/