Flutter-设置SearchDelegate的搜索提示样式

时间:2020-04-13 18:21:41

标签: flutter search hint textstyle

看看Flutter的源代码,我可以看到只能使用 theme.inputDecorationTheme.hintStyle 进行推断,有什么方法可以简单地将其传递给构造函数吗?

编辑:目前无法执行此操作,只能覆盖 appBarTheme 方法。我关闭线程,因为这似乎是实现它的唯一方法。

1 个答案:

答案 0 :(得分:1)

有一种方法可以对此进行覆盖

  @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
      ),
    );
  }