appBarTheme method

ThemeData appBarTheme(
  1. BuildContext context
)

用于配置搜索页面的主题。

返回的 ThemeData 将用于包装整个搜索页面,因此它可用于使用适当的主题属性配置其任何组件。

除非被重写,否则默认主题将配置包含搜索输入文本字段的应用栏,该字段具有白色背景,浅色主题 上具有黑色文本。对于深色主题,默认值为深灰色背景和浅色文本。

另请参阅:

Implementation

ThemeData appBarTheme(BuildContext context) {
  final ThemeData theme = Theme.of(context);
  final ColorScheme colorScheme = theme.colorScheme;
  return theme.copyWith(
    appBarTheme: AppBarTheme(
      backgroundColor: colorScheme.surface,
      iconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey),
      titleSpacing: 0.0,
      elevation: 0,
    ),
    inputDecorationTheme: searchFieldDecorationTheme ??
        Theme.of(context).inputDecorationTheme.copyWith(
          prefixIconColor: colorScheme.outlineVariant,
          suffixIconColor: colorScheme.outlineVariant,
          contentPadding: EdgeInsets.zero,
          hintStyle: searchFieldStyle,
          border: OutlineInputBorder(
            borderSide: BorderSide.none,
            borderRadius: BorderRadius.circular(8.0),
          ),
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide.none,
            borderRadius: BorderRadius.circular(8.0),
          ),
          filled: true,
        ),
  );
}