未布局RenderBox:导致错误的相关小部件为ExpansionTile [英] RenderBox was not laid out : The relevant error-causing widget was ExpansionTile
本文介绍了未布局RenderBox:导致错误的相关小部件为ExpansionTile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个ExpansionTile
小部件,在展开它时使用ListView.Builder
显示一个搜索文本字段和图书列表,但它向我发送此错误
RenderBox was not laid out: RenderRepaintBoundary#6b9d7 NEEDS-LAYOUT NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
package:flutter/…/rendering/box.dart:1
Failed assertion: line 1929 pos 12: 'hasSize'
The relevant error-causing widget was
ExpansionTile
以下是代码
return SafeArea(
child: Container(
padding: EdgeInsets.all(16.0),
color: Color(int.parse(bodycolor)),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Column(children: [
ExpansionTile(
leading: Icon(Icons.info_rounded,
color: HexColor("#5344ed")),
title: Text(
"Select Staff",
style: GoogleFonts.montserrat(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: HexColor("#5344ed")),
),
children: [
buildSearch(),
ListView.builder(
shrinkWrap: true,
itemCount: books.length,
itemBuilder: (context, index) {
final book = books[index];
return ListTile(
title: Text(book.title),
subtitle: Text(book.author),
);
},
)
]),
])),
),
更新:
我编辑我的代码,结果是这样的输出。
如果有人知道如何执行此操作,请帮助。
推荐答案
尝试以下代码,希望对您有帮助
您的列表->;
List<String> data = [
"Counter No 1",
"Counter No 2",
"Counter No 3",
"Counter No 4",
];
您的小工具->;
SingleChildScrollView(
child: Column(
children: [
// your other widget
buildSearch(),
ExpansionTile(
leading: Icon(
Icons.info_rounded,
),
title: Text(
"Select Staff",
),
children: [
ListView.builder(
shrinkWrap: true,
itemCount: data.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(data[index]),
subtitle: Text('Your Data'),
);
},
),
],
),
],
),
),
您还将我的答案引用为ExpansionPanel
这篇关于未布局RenderBox:导致错误的相关小部件为ExpansionTile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文