flutter - RenderBox 未布置:RenderRepaintBoundary
问题描述
我在使用 listview builder 时遇到错误,不知道如何解决。如果我删除 Listview 构建器代码,那么它不会给出错误。
这是代码。
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'),),),
],
),
);
}),
),
我该如何解决这个问题?
解决方案
您可以尝试为保存您的列表视图的容器设置高度
Container(
height: 200.0, //for example
child: ListView.builder(
//your code
)
)
推荐阅读
- mysql - 用于更改工作台中存在的所有模式的 SQL 查询?
- javascript - 分页在php网页中的page2上不起作用
- haskell - 字符串加倍?
- python - 用于命名字符串常量的 Python 构造
- python - 通过python合并两个外部边缘
- python-3.x - 如何自动将图像传输到文件夹
- c++ - list::iterator 对移至列表无效?
- javascript - 使用 google drive api 将 MediaStream Recorder 块上传到 Google Drive?
- php - Laravel如何从现在工作的数据库中获取餐馆?
- c# - WinForms Close() 事件后 Revit API 外部命令冻结