简体   繁体   中英

flutter: Add a Text at the bottom of Scaffold

I am new to flutter. In my home screen I want to add a text at the bottom of the Screen displayed

home page code

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,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

result

模拟器

In this screen I want to add a text that will be displayed at the bottom. I tried an example but when I apply that, text is shown at bottom but the main text and the button goes up, I don't want that to happen.

you can use this code

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

or

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

),

you can wrap your column with stack and in stack use positioned widget like code below

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')),
              )
            ],
          )),
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM