[英]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.