How to get the first element of a list in Dart

2 Answers

0 votes
void main() {
    List<int> lst = [21, 32, 11, 71, 80, 97]; 

    print(lst.first);
}




/*
run:

21

*/

 



answered Oct 8, 2022 by avibootz
0 votes
void main() {
    List<int> lst = [21, 32, 11, 71, 80, 97]; 

    print(lst.elementAt(0));
}




/*
run:

21

*/

 



answered Oct 8, 2022 by avibootz

Related questions

1 answer 138 views
2 answers 159 views
1 answer 184 views
1 answer 164 views
1 answer 188 views
1 answer 151 views
1 answer 131 views
...