dart - 如何在 flutter 中滚动页面

我的页面代码是这样的。我需要滚动应用栏下方的部分。

@override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(... ),
      body: new Stack(
        children: <Widget>[
          new Container(
            decoration: BoxDecoration(
                image: DecorationImage(...),
          new Column(children: [
            new Container(...),
            new Container(...... ),
            new Padding(
              child: SizedBox(
                child: RaisedButton(..),
            ),
            new Divider(),
            new Column(
              children: <Widget>[
                new Container(
                  child: new Row(
                    children: <Widget>[
                      new Expanded(
                        child: new Text(  ),
                      ),
                      new IconButton(
                        icon: IconButton(..),
                        onPressed: () {
                          _changed(true, "type");
                        },
                      ),
                    ],
                  ),
                ),
                visibilityPropertyType
                    ? new Container(
                        margin: EdgeInsets.all(24.0),
                        child: new Column(
                          children: <Widget>[
                            new Row(
                              children: <Widget>[
                                new Expanded(... ),
                                new RaisedButton(..)
                              ],
                            ),
                            new Padding(
                              padding: const EdgeInsets.only(top: 10.0),
                              child: new Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceEvenly,
                                children: <Widget>[
                                  new Column(
                                    children: <Widget>[
                                      new Row(  
                                        children: <Widget>[.. ]),
                                      new Row(
                                        children: <Widget>[]),
                                      new Row(
                                        children: <Widget>[]),
                                      new Row(
                                        children: <Widget>[],
                                  ),
                                  new Column(
                                    children: <Widget>[
                                      new Row(
                                        children: <Widget>[],
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ))
                    : new Container(),
              ],
            ),
            new Divider(
              color: Colors.white,
            )
          ])
        ],
      ),
    );
  }

我需要让 body 部分可滚动。我怎样才能实现那个滚动。 如果存在任何自定义滚动方法。我试过 ScrollableSingleChildScrollView 但不符合我的需要。 当我使用 SinglechildScrollView 时,会发生错误 BoxConstraints 强制无限高度。如果我删除了 LayoutBuilder,它会导致 A RenderFlex 在底部溢出 22 个像素 错误

最佳答案

将您的小部件树包装在 SingleChildScrollView 中:

 body: SingleChildScrollView(
child: Stack(
    children: <Widget>[
      new Container(
        decoration: BoxDecoration(
            image: DecorationImage(...),
      new Column(children: [
        new Container(...),
        new Container(...... ),
        new Padding(
          child: SizedBox(
            child: RaisedButton(..),
        ),
....
...
 ); // Single child scroll view

请记住,SingleChildScrollView 只能有一个直接小部件(就像 Android 中的 ScrollView)。

https://stackoverflow.com/questions/51765092/

相关文章:

flutter - InkWell 在 Flutter 中的 GridTile 中的图像顶部产生波纹

ios - Flutter:如何创建一个新项目

flutter - 如何获得 ScrollController 的全尺寸

flutter - 如何在 Flutter 中对齐单个小部件?

dart - 使 BoxDecoration 图像褪色/透明

dart - 如何从另一个小部件设置状态?

dart - TabController 构造函数中的 `vsync` 属性

flutter - 如何获取 Flutter 应用的构建和版本号

Flutter - 垂直分频器和水平分频器

dart - 我可以将 Map 存储在 Dart 的共享首选项中吗?