【问题标题】:How to change color of the bubble (under cursor) on EditText in Flutter如何在 Flutter 中的 EditText 上更改气泡的颜色(光标下)
【发布时间】:2020-05-26 13:25:02
【问题描述】:

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

Here 是同一个问题,但适用于本机代码。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以使用textSelectionHandleColor 属性。

    Theme(
              data: Theme.of(context).copyWith(
                textSelectionHandleColor: Colors.green, 
              ),
              child: TextField(),
            );
    

    【讨论】:

      【解决方案2】:

      根据this flutter documentationtextSelectionHandleColor 已被弃用。您应该使用 selectionHandleColor 而不是在 TextSelectionThemeData 小部件中,如下面的代码。

        theme: ThemeData(
         
          textSelectionTheme: TextSelectionThemeData(
            cursorColor: Colors.red,
            selectionColor: Colors.green,
            selectionHandleColor: Colors.black,
          ),
        )
      

      【讨论】:

        猜你喜欢
        • 2016-05-22
        • 2017-04-14
        • 2021-10-03
        • 1970-01-01
        • 1970-01-01
        • 2012-07-23
        • 2021-11-19
        • 1970-01-01
        • 2022-08-15
        相关资源
        最近更新 更多