RenderBox không được bố trí: RenderRepaintBoundary
Oct 07 2020
Tôi gặp lỗi với trình tạo listview và không biết cách giải quyết. Nếu tôi xóa mã trình tạo Listview thì nó không gây ra lỗi.
Đây là mã.
Widget build(BuildContext context) {
return Theme(
isMaterialAppTheme: true,
data: ThemeData(
),
child:Scaffold(
backgroundColor: _dark ? null : Colors.grey.shade200,
key: _scaffoldKey,
appBar: myAppBar(),
endDrawer: myDrawer(),
body: Stack(
children: <Widget>[
SingleChildScrollView(
child: Stack(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(16.0, 10.0, 16.0, 16.0),
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
color:Colors.grey,
// color: Colors.orange,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(4.0),
bottomRight: Radius.circular(4.0))),
padding: EdgeInsets.symmetric(horizontal:16.0, vertical: 15.0),
width: double.infinity,
child: Text("Booking Details",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18.0,
// fontWeight: FontWeight.bold,
color: Colors.white,
letterSpacing: 3,
wordSpacing: 3
),),
),
],
),
SizedBox(height: 20.0),
Container(
child: new ListView.builder(
itemCount: lists.length,
itemBuilder: (BuildContext context, int i) {
return Card(
margin:
const EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 0.0),
child: new ExpansionPanelList(
expansionCallback: (int index, bool status) {
setState(() {
_selectedIndex= index;
_selectedIndex = _selectedIndex == i ? null : i;
});
},
children: [
new ExpansionPanel(
isExpanded: _selectedIndex == i,
headerBuilder: (BuildContext context,
bool isExpanded) =>
new Container(
padding:
const EdgeInsets.only(left: 15.0),
alignment: Alignment.centerLeft,
child: new Text(
'list-$i', )), body: new Container(child: new Text('content-$i'),),),
],
),
);
}),
),
Làm cách nào để khắc phục sự cố?
Trả lời
Kennedypz Oct 07 2020 at 17:59
Bạn có thể thử đặt chiều cao cho vùng chứa đang chứa chế độ xem danh sách của bạn
Container(
height: 200.0, //for example
child: ListView.builder(
//your code
)
)