【问题标题】:Problem with scrolling body of my Flutter web page我的 Flutter 网页的滚动正文出现问题
【发布时间】:2020-08-15 21:11:14
【问题描述】:

我正在尝试制作我的第一个颤振网页。 我想在顶部和可滚动区域制作导航应用栏,下面有图片和文字。 我在重新调整我的页面时遇到了问题。我的页面正文没有滚动,它在底部溢出。我做错了什么? 这是我的示例代码:

  @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】:

    您可以将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,
                )
              ],
            ),
          ),
        ],
      );
    }
    

    【讨论】:

    • 但在这个解决方案中,TopBar 也会滚动,我不想要它。我希望 TopBar 在页面顶部是静态的。对不起,我没有在我的问题中提到它......
    • 别担心,我更新了代码,如果没有帮助,请告诉我
    • 看起来不错。我现在不在我的电脑上,但我明天会试试,我会告诉你
    • 没问题。
    猜你喜欢
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    • 2022-11-15
    • 2023-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多