我正在尝试制作我的第一个网页。我要使导航应用程序栏位于顶部,并在可滚动区域下方显示图片和文字。而且我在调整页面方面遇到了问题。我的页面正文没有滚动,并且在底部溢出。我做错了什么?这是我的示例代码:
@override
Widget build(BuildContext context) {
return Column(
children: [
TopBar(),
SingleChildScrollView(
child: Column(
children: [
Container(
height: 300,
color: Colors.red,
),
Container(
height: 300,
color: Colors.green,
),
Container(
height: 300,
color: Colors.black,
)
],
),
)
],
);
}
}
您可以像这样组合Column
和ListView
:
@override
Widget build(BuildContext context) {
return Column(
children: [
AppBar(),
Expanded(
child: ListView(
children: [
Container(
height: 300,
color: Colors.red,
),
Container(
height: 300,
color: Colors.green,
),
Container(
height: 300,
color: Colors.black,
)
],
),
),
],
);
}