我想让文本小部件变成Flutter上的Flex End。
这里我的代码:
return MaterialApp(
title: 'Nature',
home: Scaffold(
appBar: AppBar(
title: Text('John Doe'),
),
body: Center(
child: Text('Copyright © 2020'),
),
),
我想要我的小部件底部的文本。
- 选项一:屏幕上只有
Text()
return MaterialApp(
title: 'Nature',
home: Scaffold(
appBar: AppBar(
title: Text('John Doe'),
),
body: Align(
alignment: Alignment.bottomCenter,
child: Text('Copyright © 2020'),
),
),
);
- 选项二:底部的
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')),
),
],
),
),
);
请尝试这个。。。
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'),
)),
],
),
),
);
我认为scaffold小部件的底部页是在屏幕底部编写任何内容的最佳方式。
Scaffold(
bottomSheet: Container(
child: Text("Copyright © 2020"),
),
body: Container(
....