扑改变焦点颜色和图标颜色,但行不通
更改焦点颜色和图标颜色,但不起作用,
TextFormField(
cursorColor: Colors.red[600],
decoration: const InputDecoration(
border: UnderlineInputBorder(),
filled: false,
iconColor: Colors.red,
focusColor: Colors.red,
icon: Icon(Icons.phone),
hintText: 'Where can we reach you?',
labelText: 'Phone Number *',
prefixText: '+86',
),
keyboardType: TextInputType.phone,
onSaved: (String? value) {
this._phoneNumber = value;
print('phoneNumber=$_phoneNumber');
},
// TextInputFormatters are applied in sequence.
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
),
我将焦点颜色和图标颜色更改为红色。我确实重新启动,但输出仍然是蓝色的。我的主题主要颜色也是红色。
theme: ThemeData(primaryColor: Colors.red, fontFamily: 'Poppins'),
问题是什么? 这是当前输出。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想更改焦点上的图标颜色,则可以使用此方法
If you wish to change the color of Icon on focus then you can use this instead
来自 intical文档这是可用的:
因此,您的代码可能是:
好处是,如果您愿意,可以将此InputDecoration设置为整个应用程序,仅一次使用
theme> theme
proterty在pocity> posital> pocity> portialapp /代码>小部件,并将在任何地方应用。
From the offical documentation this is available:
Your code could therefore be:
The good thing with this is that you can, if you want, set this inputDecorationTheme to be applied for the entire app just once using the
theme
property on theMaterialApp
widget, and will be applied everywhere.尝试使用
focusnode
。此外,请详细介绍焦点节点
有关 a>
Try using
FocusNode
.Also, dispose the focus node
More about
FocusNode