简体   繁体   English

TextFormField,更改图标和文本颜色

[英]TextFormField, change icon and text colors

I want to change the labelText and the icon colors of my TextFormField when it's highlighted.我想在突出显示时更改我的TextFormFieldlabelTexticon颜色。 This is my code:这是我的代码:

TextFormField(
            enabled: enable,
            controller: textEditingController,
            obscureText: obscureText,
            validator: validate,
            keyboardType: keyboardType,
            decoration: InputDecoration(
              focusedBorder: UnderlineInputBorder(
                borderSide:
                    BorderSide(color: Colors.yellow),
              ),
              border: UnderlineInputBorder(),
              enabledBorder: _checkBorder(),
              labelText: labelText,
              prefixIcon: Padding(
                padding: EdgeInsets.all(distanceIconFromEdges),
                child: icon,
              ),
              hintText: hintText,
            ))

Wrap your TextFormField in Theme and change accentColor将您的TextFormField包裹在Theme并更改accentColor

Theme(
  data: Theme.of(context).copyWith(accentColor: Colors.red),
  child: TextFormField(...),
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM