返回小部件以保持填充和对齐方式

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

我正在尝试构建一个返回一些按钮的应用程序,但是当我从另一个类中返回按钮时,它们将失去所有的填充和对齐方式。

例如,此代码创建了5个位于屏幕底部的按钮:

Column(
      mainAxisAlignment: MainAxisAlignment.end,
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.only(bottom: 11.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              FloatingActionButton(
                onPressed: () {},
                child: const Icon(Icons.undo),
                splashColor: Colors.pink[900],
                backgroundColor: Colors.pink[250],
              ),
              FloatingActionButton(
                onPressed: () {},
                child: const Icon(Icons.cancel),
                splashColor: Colors.pink[900],
                backgroundColor: Colors.pink[250],
              ),
              FloatingActionButton(
                onPressed: () {},
                child: const Icon(Icons.favorite),
                splashColor: Colors.pink[900],
                backgroundColor: Colors.pink[250],
              ),
              FloatingActionButton(
                onPressed: () {},
                child: const Icon(Icons.check_circle),
                splashColor: Colors.pink[900],
                backgroundColor: Colors.pink[250],
              ),
              FloatingActionButton(
                onPressed: () {},
                child: const Icon(Icons.share),
                splashColor: Colors.pink[900],
                backgroundColor: Colors.pink[250],
              ),
            ],
          ),
        ),
      ],
    );

但是,如果我从另一个.dart文件返回此代码,就像这样:

  Widget build(BuildContext context) {
    _controller.forward();
    return FadeTransition(
      opacity: _animation,
      child: Column(
        children: <Widget>[
          SurpriseImage(),
        ],
      ),
    );
  }

这些按钮最终显示在屏幕顶部。

为什么会这样?

flutter dart
1个回答
0
投票

MainAxisAlignment.end将仅确保按钮位于Column Widget的末尾,但没有确保此Widget到达屏幕的底部

© www.soinside.com 2019 - 2024. All rights reserved.