如何在Flutter中的小部件内对齐按钮

问题描述

尝试做一些小改变而不必支付开发人员费用...。我想将按钮对准屏幕底部,但似乎只能将其放在可滚动文本区域内。它必须显示在屏幕上,以便观看者不必滚动即可查看按钮。

enter image description here

这是该页面上的代码

Widget showEveryday2Card() {
    return FlipCard(
      onFlip: () => _sound.playLocal("shuffle.mp3"),direction: FlipDirection.HORIZONTAL,// default
      //front: Image.asset('images/cards/24.png'),front: Container(
        color: Colors.white,child: Align(
          alignment: Alignment.center,child: Image.asset('images/cards/24.png'),),back: Container(
        color: Colors.white,child: Stack(children: <Widget>[
          Positioned.fill(
            child: Align(
              alignment: Alignment.center,child: Image.asset('images/cards/cardbacks/back24.png'),Center(
            child: Container(
              padding: EdgeInsets.only(
                  top: (MediaQuery.of(context).size.height > 800)
                      ? 20
                      : (MediaQuery.of(context).size.height > 700) ? 10 : 0),height: 0.5 * MediaQuery.of(context).size.height,width: 0.8 * MediaQuery.of(context).size.width,child: Center(
                child: CupertinoScrollbar(
                  isAlwaysShown: true,controller: _controller,child: ListView(children: <Widget>[
                    Text(
                      "Scrollable text",style: TextStyle(
                        fontFamily: 'GillSansMT',fontWeight: FontWeight.normal,color: Colors.black,fontSize: (MediaQuery.of(context).size.height > 900)
                            ? 30
                            : 14,new RaisedButton(
                      onpressed: () {
                        Navigator.pop(context);
                        },child: Text('Go back!'),)
                  ]),]),);
  }

如果您能指出正确的方向,我将不胜感激。

谢谢!

解决方法

return FlipCard(
  onFlip: () => _sound.playLocal("shuffle.mp3"),direction: FlipDirection.HORIZONTAL,// default
  //front: Image.asset('images/cards/24.png'),front: Container(
    color: Colors.white,child: Align(
      alignment: Alignment.center,child: Image.asset('images/cards/24.png'),),back: Container(
    color: Colors.white,child: Stack(children: <Widget>[
      Positioned.fill(
        child: Align(
          alignment: Alignment.center,child: Image.asset('images/cards/cardbacks/back24.png'),Center(
        child: Container(
          padding: EdgeInsets.only(
              top: (MediaQuery.of(context).size.height > 800)
                  ? 20
                  : (MediaQuery.of(context).size.height > 700)
                      ? 10
                      : 0),height: 0.5 * MediaQuery.of(context).size.height,width: 0.8 * MediaQuery.of(context).size.width,// Made some changes here
          child: Column(children: [
            Expanded(
              child: CupertinoScrollbar(
                  isAlwaysShown: true,controller: _controller,child: ListView(children: <Widget>[
                    Text("Scrollable text" * 1000,style: TextStyle(
                          fontFamily: 'GillSansMT',fontWeight: FontWeight.normal,color: Colors.black,fontSize:
                              (MediaQuery.of(context).size.height > 900)
                                  ? 30
                                  : 14,))
                  ])),// SizedBox(height: 10),// Uncomment if you need some space
            RaisedButton(
              onPressed: () {
                Navigator.pop(context);
              },child: Text('Go back!'),)
          ]),]),);

尝试用此代码替换功能主体。