我有以下应用栏在 flutter ,并试图对齐标题下的潜文本“您想要的公司名称”输入。我尝试了不同的方法,但仍然无法对齐。它应该在顶部有“输入”,然后是潜台词对齐中心
这是我当前的代码
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(75.0),
child: AppBar(
centerTitle: true,
title: Text('enter'),
actions: <Widget>[
new Container(),
new Center(
child: Text(
'Your desired business name',
textAlign: TextAlign.center,
style: new TextStyle(
fontSize: 14.0,
color: Colors.white,
),
)),
],
)),
);
}
最佳答案
要对齐 AppBar
标题下的文本,您可以使用 AppBar 的 bottom
属性,该属性将 PreferredSize
小部件作为参数,也可以帮助您调整AppBar的高度根据你的需要。
这是代码
AppBar(
title: Text('Title 1'),
centerTitle: true,
bottom: PreferredSize(
child: Text("Title 2"),
preferredSize: Size.zero),
)
https://stackoverflow.com/questions/53880293/
相关文章:
flutter - 如何删除 Flutter IconButton 大填充?
flutter - BottomAppBar float 操作按钮缺口/插图不透明
git - 如何解决 Flutter 上的 "Unable to find git in your
android - Flutter dart 调试器断点停止工作
flutter - 用容器包装脚手架以获得渐变背景,如何在 flutter 中将渐变设置为容器背景?
dart - Flutter - 为什么 slider 不会在 AlertDialog 中更新?