6

如何更改在 Text 或 TextFormField 或 Flutter 中选择文本时出现的气泡颜色?

是相同的问题,但对于本机代码。

4

2 回答 2

9

您可以使用textSelectionHandleColor属性。

Theme(
          data: Theme.of(context).copyWith(
            textSelectionHandleColor: Colors.green, 
          ),
          child: TextField(),
        );
于 2020-02-11T07:24:34.193 回答
8

根据这个颤振文档textSelectionHandleColor不推荐使用。您应该在小部件selectionHandleColor内部使用,TextSelectionThemeData如下面的代码。

  theme: ThemeData(
   
    textSelectionTheme: TextSelectionThemeData(
      cursorColor: Colors.red,
      selectionColor: Colors.green,
      selectionHandleColor: Colors.black,
    ),
  )
于 2021-04-08T12:48:06.717 回答