dart - Appbar 前导属性中的文本小部件 - 但无法正确显示
问题描述
我想使用带有文本“返回”按钮的 Appbar 我使用下面的代码,但“返回”出现在下面的两行中,Appbar 标题也向下移动。
巴
ck
相同的颤振代码
final topAppBar = AppBar(
// elevation: 0.1,
backgroundColor: Color.fromRGBO(0, 113, 188, 1.0),
title: Text(
"MyAppBar",
style: TextStyle(
color: Colors.white,
fontFamily: 'Raleway-ExtraBold',
fontWeight: FontWeight.w900,
fontSize: 20.0,
),
),
leading: Padding(
padding: const EdgeInsets.only(left: 0),
child: FlatButton(
child: Text(
"Back",
// textDirection: TextDirection.ltr,
style: TextStyle(
color: Colors.white,
fontFamily: "Raleway-Medium",
fontSize: 14.0,
),
),
),
),
);
有什么我在这里想念的吗?
解决方案
使用 --FittedBox
属性fit:
调整前导小部件。
leading: FittedBox(
fit: BoxFit.cover,
child: FlatButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, // add this to remove padding.
onPressed: () {},
child: Text(
"Back",
// textDirection: TextDirection.ltr,
style: TextStyle(
color: Colors.white,
fontFamily: "Raleway-Medium",
fontSize: 14.0,
),
),
),
),
推荐阅读
- java - .jar 文件的手册页?
- javascript - 如果 keepfocus 设置为 false,react-day-picker 不会关闭
- javascript - 复选框 True/False - 添加到计算
- swift - MacOS 在 StatusBar 上创建 ProgressBar
- vba - 如何将工作表设置为变量以获取更多方法(带循环)
- reactjs - Axios 获取带有标头的请求不起作用
- amazon-web-services - 无法在 AWS Quick Sight 中解析来自 S3 的 JSON 文件
- java - 文本字段中的返回值
- rmi - 如何在不出现 UnmarshallException 的情况下关闭 RMI-Server?
- python - 如何发送公式而不是结果?