我想删除默认后退按钮的背景颜色。我有以下配置,但它仍然像照片中那样。适用于所有输入的 TIA。
hightlightColor: Colors.transparent,
splashColor: Colors.transparent,
splashFactory: NoSplash.splashFactory,
提前致谢。
这是一个透明背景的后退按钮:
BackButton(
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.transparent),
surfaceTintColor: MaterialStatePropertyAll(Colors.transparent),
)
),
将其用作可重复使用的小部件,因为如果您尝试处理
Theme
,要更改后退按钮,您将被迫更改所有 IconButton
主题。因为后退按钮被视为 IconButton。
ThemeData(
iconButtonTheme: IconButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.transparent,)
// will be applied to all of the IconButtons
)
),
那是因为前导小部件不仅仅是为后退按钮制作的,它接受任何小部件。
因此,建议将其用作可重用的小部件。
希望对您有帮助。