Print a list in flutter

To print a list including square brackets we just use the simple print method.

Example:

void main[]{ var myList = [1, 2, 3, 4, 5]; print[myList]; }

Output:

[1, 2, 3, 4, 5]

If you do not want to print the square brackets means you just want to print the contents of the list, here is the solution

Example:

void main[]{ var myList = [1, 2, 3, 4, 5]; print[myList.join[',']]; }

Output:

1,2,3,4,5

print list in flutter code example

Example: get single element from list in dart

var firstList = [1,2,3,4,5,6]; print[firstList.firstWhere[[i] => i i.length > 3]]; // three

Video liên quan

Chủ Đề