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

RenderShrinkWrappingViewport does not support returning intrinsic dimensions

I want a text button when on click shows a simpleDialog vith a listView.builder but I don’t know how to code it. I always have an error.
Can you help me?

Here is my code:

TextButton(
    child: const Text('Selet instruments needed'),
    onPressed: () {
      showDialog(
          context: context,
          builder: (BuildContext context) => SimpleDialog(
                  contentPadding: const EdgeInsets.all(15),
                  title: const Text('Select instruments needed'),
                  children: [
                    ListView.builder(
                        shrinkWrap: true,
                        itemCount: 2,
                        itemBuilder: ((context, index) {
                          return ListTile(
                              title: instrumentType[index]['name'],
                              onTap: () {});
                        }))
                  ]));
    })

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

>Solution :

You can wrap your ListView with SizedBox widget and using LayoutBuilder help to get the constraints

  TextButton(
        child: const Text('Selet instruments needed'),
        onPressed: () {
          showDialog(
            context: context,
            builder: (BuildContext context) => LayoutBuilder(
              builder: (context, constraints) => SimpleDialog(
                contentPadding: const EdgeInsets.all(15),
                title: const Text('Select instruments needed'),
                children: [
                  SizedBox(
                    height: constraints.maxHeight * .7, // 70% height
                    width: constraints.maxWidth * .9,
                    child: ListView.builder(
                      physics: NeverScrollableScrollPhysics(),
                      itemCount: 44,
                      itemBuilder: ((context, index) {
                        return ListTile(onTap: () {});
                      }),
                    ),
                  )
                ],
              ),
            ),
          );
        })
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