flutter - 我怎么能在这个屏幕的底部有文本?
问题描述
我目前有一个页面/屏幕在按下 FAB 后打开。在此页面/屏幕上,我想在最底部放置文本(尝试在此处显示日期),但我不确定如何使用我布置小部件的方式来做到这一点。
在页面上,我构建了 Widget,如下所示:
Widget build(BuildContext context) {
return WillPopScope(
child: Scaffold(
appBar: AppBar(title: const Text('Add Object')), body: body(context),
),
onWillPop: () async {
return true;
}
);
}
其中引用了我的 Widget 正文:
Widget body(BuildContext ctx) {
return Container(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Flexible(
child: Container(
padding: EdgeInsets.all(5),
child: EditableText(
controller: titleController,
focusNode: titleFocus,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.blue,
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.bold,
)
)
),
),
Divider(),
Flexible(
child: Container(
padding: EdgeInsets.all(5),
child: EditableText(
controller: contentController,
maxLines: 600,
focusNode: contentFocus,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.red,
style: TextStyle(
color: Colors.white,
fontSize: 20
)
)
)
),
],
)
);
}
使用这种布局,我将如何将文本放在最底部?我在想一个底部导航栏,但如果我只是想在底部放一些文本,我认为这不是正确的用法。
解决方案
您可以在 Expanded 中使用 Align 小部件
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: Text('Something'),
),
)
推荐阅读
- python - Django:重定向到查看调用登录的位置
- javascript - 将多个范围复制到另一张工作表的脚本(Google 表格)
- java - Python os.system() shell 的 java 版本与 travis 构建环境不同
- javascript - 使用机器人对 JS (Discord.js) 中的区域指标符号做出反应
- css - 为什么我的 CSS only 单选按钮没有被选中?
- javascript - 使 div 跟随光标滚动到鼠标移动
- python - 检查数据库中是否存在加密密码
- python - MatPlotLib 随机绘制颜色
- java - 使用 Java/Maven 将数据存储在文本文件中
- python - Sqlalchemy 没有关闭连接