0

I would like to display chips inside of a horizontal scrollview, and display as many rows as can fit in a specified SizedBox height. Any chip that doesn't fit on the screen should be scrolled to horizontally, as shown in the image below. However, I would like to have the chips next to each other rather than in these fixed column sizes (i.e. the "eating healthy" and "pulse checks" chips should be right next to each other. My code looks something like this:

SizedBox(
  height: 200,
  child: SingleChildScrollView(
    direction: Axis.horizontal
    child: Wrap(
      direction: Axis.vertical,
      runSpacing: 10.0,
      spacing: 8.0,
      children: chipNames
          .map(
            (e) => SelectableChip(
              label: e,
              modChipSelected: modChipEmotion,
            ),
          )
          .toList(),
    ),
  ),
);

And this is what I'm getting (the SizedBox correctly determines the height and the horizontal scrollview works, I'm just getting deadspace in between columns):

Flutter chip image

4
  • can you share SelectableChip code part, Commented Dec 18, 2021 at 18:49
  • 1
    It's basically an InputChip wrapped in an AnimatedBuilder for a color change onPressed.
    – J Olson
    Commented Dec 18, 2021 at 19:02
  • it took the maximum width for all elements Commented Dec 18, 2021 at 19:36
  • Yeah, I want to avoid that
    – J Olson
    Commented Dec 18, 2021 at 22:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.