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!
you can achieve your result using FocusNode like below
FocusNode focus = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Alberts trial AppBar'),
),
body: TextFormField(
focusNode: focus,
onTap: () => {FocusScope.of(context).requestFocus(focus)},
decoration: InputDecoration(
filled: true,
fillColor: focus.hasFocus ? Colors.green : Colors.red),
));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.