List<String> checkLength(List<String> input) {
if (input.length > 6) {
var tempOutput = input;
while (tempOutput.length > 6) {
var difference = (tempOutput.length/6).round() + 1;
for (int i = 0; i < tempOutput.length - 1; i + difference) {
tempOutput.removeAt(i); //Removing the value from the list
}
}
return tempOutput; //Return Updated list
} else {
return input;
}
}
我想从临时列表中删除某些内容。为什么它不起作用?我没有看到它是如何修复的,在我解决的其他问题中,我使用了类似的方法,它工作(即使几乎相同)什么使得这是Dart中的一个固定长度列表?
请注意我对Dart有点新,所以请原谅我这种问题,但我找不出解决方案。
查找达特链接
请将代码作为文本直接添加到您的问题中,而不是链接的屏幕截图。 –
你如何创建列表?如果你做'新列表(6)',它将变成一个固定长度的列表,有6个条目。 –
checkLength(arrayToSingularElements(toColorBlockArray(input)))。join(''); –