flutterflutter-theme

remove default backbutton background color


I would like to remove the background color of the default backbutton. I have below configurations but it still appears like in the photo. TIA for all inputs.

enter image description here

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

Thanks in advance.


Solution

  • I found a way to override the theming in the whole app. Set the following in ThemeData and provide it to theme in MaterialApp.

    iconButtonTheme: IconButtonThemeData(
            style: ButtonStyle(
              overlayColor: MaterialStateProperty.all(Colors.transparent),
              splashFactory: NoSplash.splashFactory,
            ),
          ),
    

    Additionally, to remove all tooltip in the automaticallyImplyLeading button, I came across the following:

    class BackButtonOverride extends DefaultMaterialLocalizations {
      BackButtonOverride(Locale locale) : super();
    
      @override
      String get backButtonTooltip => '';
    }
    
    class BackButtonDelegate
        extends LocalizationsDelegate<MaterialLocalizations> {
      const BackButtonDelegate();
      @override
      Future<BackButtonOverride> load(Locale locale) {
        return SynchronousFuture(BackButtonOverride(locale));
      }
    
      @override
      bool shouldReload(BackButtonDelegate old) => false;
      @override
      bool isSupported(Locale locale) => true;
    }
    

    and applied to MaterialApp as follows:

    localizationsDelegates: const [
                  BackButtonDelegate(),
                ],