skip to Main Content
Wrap(
        children: List.generate(channelIds.length,
            (index) => chipItem(channelIds[index], AppUtils.filteredByChannelId)),
      ),

So I have used List.generate but I want to display items in horizontally. I applied,

direction: Axis.horizontal,

In a Wrap, I gave a direction but it is not working.

3

Answers


  1. Chosen as BEST ANSWER
    return SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Wrap(
            direction: Axis.horizontal,
            children: List.generate(
                channelIds.length,
                (index) =>
                    chipItem(channelIds[index], AppUtils.filteredByChannelId)),
          ),
        );
    

    above code works for me


  2. instead of using List.generate use this

      Wrap(
      children: [
        for(var item in channelIds)
          your widget here
      ],
    ),
    
    Login or Signup to reply.
  3. use like this

     return Wrap(
        children: ['1']
            .asMap()
            .map((i, element) => MapEntry(i, Text(i.toString())))
            .values
            .toList(),
     );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search