颤动:在脚手架底部添加文本

时间:2020-09-19 09:29:55

标签: android android-studio flutter dart

我是新手。在我的主屏幕中,我想在显示的屏幕底部添加文本

主页代码

Scaffold buildUnAuthScreen(){
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topRight,
            end: Alignment.bottomLeft,
            colors: [
              Theme.of(context).accentColor,
              Theme.of(context).primaryColor,
            ]
          ),
        ),
        alignment: Alignment.center,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text('FriendsHive',
            style: TextStyle(
              fontFamily: 'Signatra',
              fontSize: 90.0,
              color: Colors.white,
            ) ,
            ),
            GestureDetector(
              onTap: login,
              child: Container(
                width: 260.0,
                height: 60.0,
                decoration: BoxDecoration(
                  image: DecorationImage(image: AssetImage('assets/images/google_signin_button.png'),
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

结果

Emulator

在此屏幕上,我想添加一个文本,该文本将显示在底部。我尝试了一个示例,但是当我应用该示例时,文本显示在底部,但主要文本和按钮都向上,我不希望发生这种情况。

2 个答案:

答案 0 :(得分:0)

您可以使用此代码

 Expanded(
      child: Align(
        alignment: FractionalOffset.bottomCenter,
         child: Text('You can try'),    
      ),
    ),

 bottomNavigationBar: BottomAppBar(
color: Colors.transparent,
child: Text('something'),
elevation: 0,

),

答案 1 :(得分:0)

您可以用堆栈包装您的列,并在stack中使用下面的代码之类的定位小部件

Scaffold(
      body: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [
                  Theme.of(context).accentColor,
                  Theme.of(context).primaryColor,
                ]),
          ),
          alignment: Alignment.center,
          child: Stack(
            children: <Widget>[
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text(
                    'FriendsHive',
                    style: TextStyle(
                      fontFamily: 'Signatra',
                      fontSize: 90.0,
                      color: Colors.white,
                    ),
                  ),
                  GestureDetector(
                    onTap: () {},
                    child: Container(
                      width: 260.0,
                      height: 60.0,
                      decoration: BoxDecoration(
                        image: DecorationImage(
                          image: AssetImage(
                              'assets/images/google_signin_button.png'),
                          fit: BoxFit.cover,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Positioned(
                bottom: 0,
                right: 0,
                left: 0,
                child: Center(child: Text('test')),
              )
            ],
          )),
    );