简体   繁体   English

Flutter SearchDelegate:如何更改文本光标中蓝色气泡的颜色并选择?

[英]Flutter SearchDelegate: How to change the color of the blue bubbles from text cursor and select?

Flutter SearchDelegate: How to change the color of the blue bubbles in search delegate widget in flutter? Flutter SearchDelegate:如何在 Flutter 中更改搜索委托小部件中蓝色气泡的颜色?

environment: sdk: ">=2.12.0 <3.0.0"环境:sdk:">=2.12.0 <3.0.0"

在此处输入图片说明

在此处输入图片说明

In my Scaffold-Appbar i have an action with an IconButton and then i call DataSearch.在我的 Scaffold-Appbar 中,我有一个带有 IconButton 的操作,然后我调用了 DataSearch。 Then i set the ThemeData appBarTheme in the DataSearch.然后我在 DataSearch 中设置 ThemeData appBarTheme。 Thats it.而已。

      appBar: AppBar(
        title: Text(widget.title),
        actions: [
          IconButton(
            icon: const Icon(Icons.search),
            onPressed: () {
              showSearch(context: context, delegate: DataSearch());
            },
          ),
        ],
      ),


class DataSearch extends SearchDelegate<String> {
  @override
  ThemeData appBarTheme(BuildContext context) {
    return ThemeData(
      textSelectionTheme: TextSelectionThemeData(
        //cursorColor: Colors.red,
        selectionHandleColor: Colors.red,
        //selectionColor: Colors.white,
      ), // cursor color
    );
  }

You can change the color within the textSelectionTheme by setting the selectionHandleColor .您可以通过设置selectionHandleColor来更改textSelectionTheme的颜色。

textSelectionTheme: TextSelectionThemeData(
        selectionHandleColor: Colors.red, // Change bubble to red
        cursorColor: Colors.white,
      ), 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter SearchDelegate:如何删除文本下方的文本下划线和蓝线(颜色)? - Flutter SearchDelegate: How to remove text underline and blue line (color) below text? 如何更改 flutter 中的 SearchDelegate StatusBarIcons 颜色或 buildSuggestions 正文颜色? - How to change SearchDelegate StatusBarIcons Color or buildSuggestions body Color in flutter? Flutter - 更改 SearchDelegate 的搜索提示文本 - Flutter - Change search hint text of SearchDelegate 如何在颤动中更改光标颜色 - How to change cursor color in flutter Flutter - 如何更改 cursor 选择的文本颜色? - Flutter - How to change the color of the text being selected by the cursor? 如何更改 flutter 中的 TextField cursor 颜色 - how to change TextField cursor color in flutter 如何在 TextField Flutter 中更改 cursor 颜色 - How to change cursor color in TextField Flutter 颤动:如何更改选择光标颜色 - flutter : How to change selectetion cursor color 如何更改flutter搜索委托中cursor的颜色? - how to change the color of the cursor in flutter search delegate? 仅当 cursor 位于 flutter 内时,如何使文本字段的边框以不同方式更改颜色 - how to make the border of a text field change color differently only when the cursor is inside flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM