List list = [1,2,3,4,5];
int index = list.indexOf(3);
print(index);//2
- remove(element) —— 删除数组中的元素,返回一个布尔值表示删除是否成功。
List list = [1,2,3,4,5];
bool result = list.remove(1);
print(result);//true
- removeAt(index) —— 删除指定位置的元素,结果返回被删除的元素。
List list = [1,2,3,4,5];
int element = list.removeAt(0);
print(element);//1
- fillRange(start,end,element) —— 填充 [start,end) 中的元素,该方法没有返回值
List list = [1,2,3,4,5];
list.fillRange(1, 2, 9);
print(list);//[1, 9, 3, 4, 5]
- insert(index,element) —— 在指定的位置插入元素,该方法没有返回值。
List list = [1,2,3,4,5];
list.insert(0, 8);
print(list);//[8, 1, 2, 3, 4, 5]
- insertAll(index,iterable) —— 在指定的位置插入多个元素,该方法没有返回值。
List