Search code examples
fluttersearchhinttextstyle

Flutter - Set search hint style of SearchDelegate


Looking at Flutter's source code I can see that this can only be inferred using theme.inputDecorationTheme.hintStyle, is there any way to simply pass it to the constructor?

EDIT: currently there's no way to do it but only to override the appBarTheme method. I close the thread since this seems to be the only way to achieve it.


Solution

  • There's a method that you can override for that

      @override
      ThemeData appBarTheme(BuildContext context) {
        assert(context != null);
        final ThemeData theme = Theme.of(context);
        assert(theme != null);
        return theme.copyWith(
          inputDecorationTheme: theme.inputDecorationTheme.copyWith(
            hintStyle: ..., // <=() here
          ),
        );
      }