I was wondering if there was an easy way to concatenate two lists in dart to create a brand new list object. I couldn\'t find anything and something like this:
My list:>
We can add all the elements of the other list to the existing list by the use of addAll()
method.
Using addAll()
method to add all the elements of another list to the existing list. and Appends all objects of iterable to the end of this list.
Extends the length of the list by the number of objects in iterable. Throws an UnsupportedError
if this list is fixed-length.
Creating lists
listone = [1,2,3]
listtwo = [4,5,6]
Combining lists
listone.addAll(listtwo);
Output:
[1,2,3,4,5,6]