Home > Mobile >  How to display List.generate horizontally in flutter
How to display List.generate horizontally in flutter

Time:01-13

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.

CodePudding user response:

instead of using List.generate use this

  Wrap(
  children: [
    for(var item in channelIds)
      your widget here
  ],
),

CodePudding user response:

use like this

 return Wrap(
    children: ['1']
        .asMap()
        .map((i, element) => MapEntry(i, Text(i.toString())))
        .values
        .toList(),
 );
  • Related