如何更改应用程序栏的抽屉/后退按钮图标的大小,而无需修改Flutter中默认提供的行为?

问题描述 投票:0回答:1

我正在尝试更改我的ThemeData中的应用栏中图标的大小(导航器提供的“ Back”和Scaffold提供的“ Drawer”,通过修改iconTheme和primaryIconTheme:

ThemeData(
    primarySwatch: Colors.blue,
    iconTheme: IconThemeData(color: Colors.grey, size: 32),
    primaryIconTheme: IconThemeData(color: Colors.grey, size: 32)
  ),

此行仅更改图标的颜色,但大小不变。

我不需要更改Flutter处理此按钮的行为,只需更改其大小即可。

flutter mobile icons appbar
1个回答
0
投票
AppBar小部件使用BackButton小部件,因此除非您从框架的另一个分支中对其进行修改,否则更改是不可能的,但是最好的方法是使用Leading属性和条件ModalRoute.of(context)? .canPop以检查是否可以弹出当前路线。例如:

AppBar( leading: ModalRoute.of(context)?.canPop == true ? IconButton( icon: Icon( Icons.arrow_back, size: 60, ), ) : null, title: Text( "Example", ), )

© www.soinside.com 2019 - 2024. All rights reserved.