【发布时间】:2019-07-06 11:19:36
【问题描述】:
【问题讨论】:
标签: flutter
【问题讨论】:
标签: flutter
用 Theme 包装并使用 copyWith 来保留其他主题数据。
Theme(data: Theme.of(context).copyWith(
textSelectionTheme: TextSelectionThemeData(
selectionColor: Colors.green)),
child: TextFormField()
)
【讨论】:
textSelectionTheme 并使用 TextSelectionThemeData 定义您喜欢的 cursorColor 和突出显示颜色。
用主题包装您的文本小部件,并将颜色分配给 ThemeData
内的 textSelectionColor 属性请参考以下代码:- 我已将文本选择颜色更改为绿色
Theme(
data: ThemeData(textSelectionColor: Colors.green),
child: TextField(
controller: _inputController,
decoration: InputDecoration(hintText: "Input"),
),
),
【讨论】:
更改ThemeData 的textSelectionColor 的值,它会为您提供所需的结果。
【讨论】: