flutter - 如何使 Appbar 的 IconButton 在颤动中居中
问题描述
我使用颤振应用程序并在应用栏中看到问题。图标按钮不在应用栏的中心。
这是我的代码。
appBar: AppBar(
automaticallyImplyLeading: false,
actions: <Widget>[
IconButton(
icon: Icon(Icons.home),
onPressed: null,
)
],
),
IconButton 不在应用栏或导航栏的中心。
解决方案
这是您可以采取的一种解决方法来实现这一点,因为操作通常在标题之后,因为文档说AppBar class。
appBar: AppBar(
automaticallyImplyLeading: false,
centerTitle: true,
title: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(Icons.home),
onPressed: null,
),
IconButton(
icon: Icon(Icons.trending_up),
onPressed: null,
),
IconButton(
icon: Icon(Icons.people_outline),
onPressed: null,
),
IconButton(
icon: Icon(Icons.person_outline),
onPressed: null,
),
IconButton(
icon: Icon(Icons.notifications_none),
onPressed: null,
),
IconButton(icon: Icon(Icons.search), onPressed: null),
IconButton(
icon: Icon(Icons.brightness_5),
onPressed: null,
),
],
)),
但也许你应该考虑在你的情况下使用 TabBar 。
推荐阅读
- javascript - 如何将 z-index 添加到传单地图中的 geojson 图层?
- c++ - 语法错误:D3DX10Core 中的标识符“TEXTMETRIC”
- c++ - 对于等待 std::future wait() 返回的函数或在循环中检查标志睡眠一段时间,哪个更适合 CPU 使用?
- mongodb - 替换所有 Mongodb 文档的文档字段中的多个字符串
- c++ - 每个线程 C++ 保护以防止重入函数调用
- javascript - 如何使 console.log(obj) 中的对象属性在 Chrome 中按字母顺序显示?
- select - ie中的量角器选择选项promise false
- python - 如何四舍五入pydatatable中的浮动值?
- python - 如何使用混合了两个变量的自定义聚合函数创建 Pandas 交叉表?
- javascript - Jest-puppeteer 测试请求拦截意外的输入结束