我正在尝试制作我的第一个 flutter 网页。 我想在顶部制作导航应用栏,并在下面制作带有图片和文本的可滚动区域。 我在重新整理页面时遇到问题。我的页面正文没有滚动,它在底部溢出。我做错了什么? 这是我的示例代码:
@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,
)
],
),
),
],
);
}
关于flutter - 我的 Flutter 网页滚动主体出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61541464/