skip to Main Content

I Have a list and items [0,1,2,3,4,5]

when i try to print this list

i get output like this: [0, 1, 2, 3, 4, 5]

But I want to get output like this

0
1
2
3
4
5

My Code:

GFButton(
            onPressed: () {
              _mainController.selected_Tags
                  .forEach((element) => print(element));
            },
            text: "Test",
          )

2

Answers


  1. Chosen as BEST ANSWER

    I solved issue;

    <pre>
    _mainController.selected_Tags.forEach((innerList) {
          innerList.forEach((element) {
            print(element);
          });
        });
    </pre>
    

  2. I’m assuming you mean the other way around in your question (without line breaks). As your code does print in multiple lines.

    Try:

    void main() {
      final List<int> numbers = [1, 2, 3, 4, 5];
      print(numbers.join('')); // --> 12345
    }
    

    it will join the numbers without anything as the delimiter. You can also join with a comma if you want:

    numbers.join(', ')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search