Search 颤振SerachDelegate修改提示文本颜色和文本字段光标颜色

Search 颤振SerachDelegate修改提示文本颜色和文本字段光标颜色,search,flutter,cursor,hint,Search,Flutter,Cursor,Hint,我正在我的Flitter应用程序中使用SearchDelegate实现搜索栏 我已经重写了ThemeData appBarTheme(BuildContext上下文)函数以返回我的主应用程序ThemeData 但是,这只会更改搜索视图,仅更改应用程序栏的颜色。它不使用主题中定义的光标或提示颜色 感谢您的建议。您是否在Apple模拟器上运行应用程序?因为cursorColor似乎依赖于平台。TextField类的文档说明cursorColor字段 默认为[ThemeData.cursorColor

我正在我的Flitter应用程序中使用SearchDelegate实现搜索栏

我已经重写了ThemeData appBarTheme(BuildContext上下文)函数以返回我的主应用程序ThemeData

但是,这只会更改搜索视图,仅更改应用程序栏的颜色。它不使用主题中定义的光标或提示颜色


感谢您的建议。

您是否在Apple模拟器上运行应用程序?因为cursorColor似乎依赖于平台。TextField类的文档说明cursorColor字段

默认为[ThemeData.cursorColor]或[CupertinoTheme.primaryColor],具体取决于[ThemeData.platform]

我必须创建一个CupertinoThemeData并将其传递到main.dart文件中我应用程序的主题数据,如下所示:

@override
Widget build(BuildContext context) {
  return MaterialApp(
    theme: appBarCursorColorTheme(context),
    home: MyHomePage(); // MySearchDelegate contained inside MyHomePage()
  );
}

ThemeData appBarCursorColorTheme(BuildContext context) {
  final ThemeData theme = Theme.of(context);
  CupertinoThemeData ctd =
    CupertinoThemeData.raw(null, Colors.white, null, null, null, null);
  return theme.copyWith(
    cupertinoOverrideTheme: ctd,
  );
}