繁体   English   中英

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

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

Flutter SearchDelegate:如何在 Flutter 中更改搜索委托小部件中蓝色气泡的颜色?

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

在此处输入图片说明

在此处输入图片说明

在我的 Scaffold-Appbar 中,我有一个带有 IconButton 的操作,然后我调用了 DataSearch。 然后我在 DataSearch 中设置 ThemeData appBarTheme。 而已。

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

您可以通过设置selectionHandleColor来更改textSelectionTheme的颜色。

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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM