Reputation: 164
Is there a way to have two different colors on TextField? One - when the focus isn't on the TextField, and the other is?
TextStyle editTextStyle =
const TextStyle(color: Color(0xffaa7420), height: 1),
and
InputDecoration inputDecoration = const InputDecoration(focusColor:Colors.black...
But it didn't work.
Thanks!
Upvotes: 0
Views: 791
Reputation: 3514
You can achieve your result using FocusNode
.
First define a FocusNode
:
FocusNode focus = FocusNode();
Then use this node in your TextField
:
TextFormField(
focusNode: focus,
onTap: () => {FocusScope.of(context).requestFocus(focus)},
decoration: InputDecoration(
filled: true,
fillColor: focus.hasFocus ? Colors.green : Colors.red),
)
Upvotes: 1