Flutter网页的滚动体问题

问题描述 投票:0回答:1

我正在尝试制作我的第一个网页。我要使导航应用程序栏位于顶部,并在可滚动区域下方显示图片和文字。而且我在调整页面方面遇到了问题。我的页面正文没有滚动,并且在底部溢出。我做错了什么?这是我的示例代码:

  @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,
              )
            ],
          ),
        )
      ],
    );
  }
}
flutter scroll flutter-layout flutter-web
1个回答
0
投票

您可以像这样组合ColumnListView

@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,
            )
          ],
        ),
      ),
    ],
  );
}
© www.soinside.com 2019 - 2024. All rights reserved.