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(''); –