How to add elements to a list in Dart

1 Answer

0 votes
void main() {
    List<int> lst = [21, 32, 11, 71, 97]; 
    
    lst.add(30);
    lst.add(40);
    
    for (var i = 0; i < lst.length; i++) {
        print(lst[i]);
    }
}




/*
run:

21
32
11
71
97
30
40

*/

 



answered Oct 8, 2022 by avibootz

Related questions

2 answers 203 views
1 answer 129 views
1 answer 146 views
1 answer 153 views
3 answers 199 views
...