首页 > 解决方案 > 如何在颤动中将容器定位在列内

问题描述

我是新手,我正在尝试将我的 RaisedButton 小部件移动到屏幕的左下角。我在stackoverflow上尝试了几乎所有现有的解决方案,但没有一个有效!

在此处输入图像描述

以上是我想要放置按钮的位置的屏幕截图

这是我的代码,

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.black87,
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              child: Text(
                "${divStuff()}",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 120.0,
                  fontFamily:
                      'PIXymbols', //PIXymbols Digit Clocks W90 Bd from onlinewebfonts.com
                ),
              ),
              alignment: Alignment.center,
            ),
            Container(
              child: RaisedButton(
                onPressed: _launchURL,
                child: new Text('Learn More'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

标签: flutterdart

解决方案


只需像这样使用 Align 小部件:

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.black87,
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
          Text(
                "${divStuff()}",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 120.0,
                  fontFamily:
                      'PIXymbols', //PIXymbols Digit Clocks W90 Bd from onlinewebfonts.com
                ),
              ),
              alignment: Alignment.center,
            ),
            Align( //The align widget
            alignment : Alignment.bottomLeft, 
              child: RaisedButton(
                onPressed: _launchURL,
                child: new Text('Learn More'),
              ),
            ),
          ],
        ),
      ),
    );
  }
} 

推荐阅读