if you have list like this …
List<String> data = ['1', '2', '3', '4', '5',..... n];
how can you remove the last three element knowing that you don’t know the length of the list, i tried to use removeRange() but it didn’t go well.
>Solution :
Try below code
void main() {
List data = ['1', '2', '3', '4', '5'];
data .length = data.length - 3;//put your how many list item you want to remove eg.1,2,3,...n
print(data);
}
Result-> [1, 2]