如何使证明内容灵活结束,颤振的底部为零

时间:2020-02-26 07:59:21

标签: flutter

我想使文本小部件成为Flutter上的Flex End。

这里是我的代码:

 return MaterialApp(
      title: 'Nature',
      home: Scaffold(
        appBar: AppBar(
          title: Text('John Doe'),
        ),
        body: Center(
          child: Text('Copyright © 2020'),
        ),
      ),

我希望我的窗口小部件文本位于底部。

3 个答案:

答案 0 :(得分:1)

  1. 选项一:屏幕上只有Text()
return MaterialApp(
      title: 'Nature',
      home: Scaffold(
        appBar: AppBar(
          title: Text('John Doe'),
        ),
        body: Align(
          alignment: Alignment.bottomCenter,
          child: Text('Copyright © 2020'),
        ),
      ),
    );
  1. 选项二:Text()位于底部,数据显示在屏幕上
return MaterialApp(
      title: 'Nature',
      home: Scaffold(
        appBar: AppBar(
          title: Text('John Doe'),
        ),
        body: ListView(
          shrinkWrap: true,
          children: [
            Container(
              height: MediaQuery.of(context).size.height - 50,
              // Your Screen Data Here
            ),
            Container(
              height: 50,
              child: Center(child: Text('Copyright © 2020')),
            ),
          ],
        ),
      ),
    );

答案 1 :(得分:0)

我认为脚手架小部件的底页是在屏幕底部写入任何内容的最佳方法。

Scaffold(
      bottomSheet: Container(
        child: Text("Copyright © 2020"),
      ),
      body: Container(
       ....

答案 2 :(得分:0)

请尝试一下...

  return MaterialApp(
  title: 'Nature',
  home: Scaffold(
    appBar: AppBar(
      title: Text('John Doe'),
    ),
    body: Stack(
      children: <Widget>[
        Align(
            alignment: Alignment.bottomCenter,
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text('Copyright © 2020'),
            )),
      ],
    ),
  ),
);