【发布时间】:2022-09-29 09:51:14
【问题描述】:
-
谢谢,但我已经尝试过了,它没有提供更改所选文本颜色的选项。
标签: flutter text themes textfield selected
标签: flutter text themes textfield selected
Flutter 不支持通过主部件中的主题声明来改变选中的文本颜色,只能改变背景颜色。您必须在每个输入 style 属性中使用 SelectableText,例如:
SelectableText(
'Example text',
style: TextStyle(color: Colors.red), // Yout text color on selected
)
【讨论】:
请看下面的代码:
Theme(
data: Theme.of(context).copyWith(
textSelectionTheme: TextSelectionThemeData(
selectionColor: Color.fromARGB(255, 0, 20, 255),
),
),
child: TextField(
style: TextStyle(color: Colors.white),
),
),
【讨论】: