删除默认后退按钮背景颜色

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

我想删除默认后退按钮的背景颜色。我有以下配置,但它仍然像照片中那样。适用于所有输入的 TIA。

enter image description here

hightlightColor: Colors.transparent,
splashColor: Colors.transparent,
splashFactory: NoSplash.splashFactory,

提前致谢。

flutter flutter-theme
1个回答
0
投票

这是一个透明背景的后退按钮:

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
        )
      ),

那是因为前导小部件不仅仅是为后退按钮制作的,它接受任何小部件。

因此,建议将其用作可重用的小部件。

希望对您有帮助。

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