Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to align items in Row with ListView.builder()

I have been trying to make design similar to this:

But getting this as the output:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

below is my code that I implemented:

                  Row(
                    children: [
                      Expanded(
                        flex: 5,
                        child: ListView.builder(
                          shrinkWrap: true,
                          scrollDirection: Axis.vertical,
                          itemCount: interests.length,
                          itemBuilder: (context, index) {
                            return interests[index];
                          },
                        ),
                      ),
                    ],
                  ),

here interests is the list:
like this:

List<Widget> interests = [
  OutlinedButton.icon(
    onPressed: null,
    icon: const Icon(Icons.add),
    label: const Text('Socializing'),
  ),
  OutlinedButton.icon(
    onPressed: null,
    icon: const Icon(Icons.add),
    label: const Text('Community Work'),
  ),
  OutlinedButton.icon(
    onPressed: null,
    icon: const Icon(Icons.add),
    label: const Text('Photography'),
  ),
...

Any ideas where I am going wrong?
p.s. If I remove expanded widget it causes error

I am implementing all this in a Dialog > SingleChildScrollableView > Column

>Solution :

Instead of using ListView, use Wrap by wrapping with a scrollable widget like SingleChildScrolView if needed.

Wrap(
  children: interests,
)

Find more about Wrap

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading