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链接中查找可用的代码