AddAll is pretty cool, but adds it at the bottom of the list.
I want to add the sorted list A on top of the sorted list B. I need list A for a different view
listA = [1, 2, 3];
listB = [4, 5, 6];
listB.addAll(listA);
// lista == [4, 5, 6, 1, 2, 3]
The easiest but maybe bad solution i can think of is to add first listA then listB to a listC.
listC = [];
listC.addAll(listA);
listC.addAll(listB);
//listc == [1, 2, 3, 4, 5, 6]
listB = []
listB.addAll(listC)
// garbage collector to gets rid of C
// listB == [1, 2, 3, 4, 5, 6];
// listA == [1, 2, 3];
This seems a bit inefficient, so I was wondering if there is a better way for this that doesn't include loops or anything thelike. Something like flutters 'addAt', like listB.addAllAt(0, listA)
To clarify, having a third list is a 'necessary evil' that i would like to avoid. I want one list that would be AB, and one list that is just A, to go back to the question, how do i add A on top of B.