请我有这个错误在我的Flutter代码.下面是我的代码:
返回脚手架(
appBar: AppBar(
backgroundColor: Colors.black,
leading: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back_ios)),
title: const Text('Categories'),
),
body: Container(
color: Colors.black,
height: double.infinity,
width: double.infinity,
transformAlignment: Alignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
child: ListView(
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
children: [
ListTile(
title: const Text(
"Option1",
style: TextStyle(color: Colors.white),
),
onTap: () {},
),
Container(height: 2, color: Colors.white),
ListTile(
title: const Text(
"Option2",
style: TextStyle(color: Colors.white),
),
onTap: () {},
),
Container(height: 2, color: Colors.white),
ListTile(
title: const Text(
"Option3",
style: TextStyle(color: Colors.white),
),
onTap: () {},
),
Container(height: 2, color: Colors.white),
ListTile(
title: const Text(
"Option4",
style: TextStyle(color: Colors.white),
),
onTap: () {},
),
],
),
),
Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('pick color'),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: pickerColor,
onColorChanged: changeColor,
)),
actions: [
ElevatedButton(
child: const Text("You gerrit now"),
onPressed: () {
setState(() =>
currentColor = pickerColor);
Navigator.of(context).pop();
},
)
],
));
},
),
const Text(
"colorpicker",
),
const Text("stuff",
style: TextStyle(
color: Colors.white,
backgroundColor: Colors.green)),
],
),
],
),
)
],
),
));
此外,下面是我的调试控制台中指向代码缺陷点的错误:
if(!约束.有界高度){
RenderBox node = this;
while (
!node.constraints.hasBoundedHeight && node.parent is RenderBox) {
node = node.parent! as RenderBox;
}
information.add(node.describeForError(
'The nearest ancestor providing an unbounded height constraint is'));
}
throw FlutterError.fromParts(<DiagnosticsNode>[
...information,
DiagnosticsProperty<BoxConstraints>(
'The constraints that applied to the $runtimeType were',
constraints,
style: DiagnosticsTreeStyle.errorProperty),
DiagnosticsProperty<Size>('The exact size it was given was', _size,
style: DiagnosticsTreeStyle.errorProperty),
ErrorHint(
'See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.'),
]);
}
我认为这是来自列表视图,我尝试了所有可能的编辑,即使是在线资源,我仍然以相同的错误结束。我将容器(最初包裹在列表视图周围)更改为sizedBox,我还将shrinkwrap设置为true,并添加了物理键和值,但没有任何改善
2条答案
按热度按时间1aaf6o9v1#
您可以为
ListTile
设置sizebox
的高度:g9icjywg2#
你需要在GestureDetector上提供
child
。另外,你可以做一些调整,比如使用scaffoldbackgroundColor
。这是一个简单的结构