我想更改突出显示的labelTexticonTextFormField颜色。这是我的代码:

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,
            ))

最佳答案

TextFormField包装为Theme并更改accentColor

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

关于flutter - TextFormField,更改图标和文本颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57493534/

10-10 18:08