我正在使用Flutter应用程序,并在Appbar中看到了一个问题。图标按钮不在应用栏的中央。
这是我的代码
appBar: AppBar(
automaticallyImplyLeading: false,
actions: <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,
),
],
),
预先感谢:)
这是您可以实现的解决方法。
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。