![飞镖 – 在颤动中更改TextField的下划线[复制],第1张 飞镖 – 在颤动中更改TextField的下划线[复制],第1张](/aiimages/%E9%A3%9E%E9%95%96+%E2%80%93+%E5%9C%A8%E9%A2%A4%E5%8A%A8%E4%B8%AD%E6%9B%B4%E6%94%B9TextField%E7%9A%84%E4%B8%8B%E5%88%92%E7%BA%BF%5B%E5%A4%8D%E5%88%B6%5D.png)
我正在使用Flutter SDK开发应用程序.当我使用
TextField小部件时,我将其聚焦,下划线变为蓝色.我需要将此颜色更改为红色,我该怎么办? 我需要改变的截图.我只想改变下划线,而不是标签颜色.
解决方法 虽然这些其他答案可能以某种方式起作用,但您绝对不应该使用它.这不是在Flutter中获得自定义主题的正确方法.
一个更优雅的解决方案如下:
final theme = theme.of(context);return new theme( data: theme.copyWith(primarycolor: colors.red),child: new TextFIEld( decoration: new inputdecoration( labelText: "Hello",labelStyle: theme.texttheme.caption.copyWith(color: theme.primarycolor),),);
同时,如果您只想显示错误(红色),请改用inputdecoration的errorText.它会自动将颜色设置为红色.
总结以上是内存溢出为你收集整理的飞镖 – 在颤动中更改TextField的下划线[复制]全部内容,希望文章能够帮你解决飞镖 – 在颤动中更改TextField的下划线[复制]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)