Below is my Alertdialog:
return AlertDialog(
title: const Text('Choose Device'),
content: ListView.builder(
shrinkWrap: true,
itemCount: listDevices.length,
itemBuilder: (_, int index) => deviceList(listDevices[index]),
),
);
Below is deviceList function:
Widget deviceList(String strDevice) => SizedBox(
height: 150.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Row(
children: <Widget>[
const Icon(Icons.toys),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(strDevice),
),
],
),
const SizedBox(
height: 20.0,
),
],
),
);
Its not displaying Listview and am getting error as:
The following assertion was thrown during paint():
RenderBox was not laid out: RenderPhysicalShape#aedc0 relayoutBoundary=up2
‘package:flutter/src/rendering/box.dart’:
Failed assertion: line 2001 pos 12: ‘hasSize’
What might be the issue? Thanks.
2
Answers
Try to wrap
ListView.builder
in aSizedBox
with a specificheight
andwidth
.You can use like this:
I opened AlertDialog box when tap on ElevatedButton like this:
I don’t changes your deviceList widget
And i clearly show AlertDialogBox with ListView. I hope it’s help you.
Happy Coding :}