I wanna change color of button when user type at least one character on textfield also wanna change color when textfield is empty
so I tryed to flag(boolean) to make it
onChanged: (value) {
if (value.length == 0) {
setState(() {
_isTimeFilled = false;
});
} else {
setState(() {
_isTimeFilled = true;
});
}
},
...
_isFilled ? Colors.grey : Colors.green
but it only change color when textfield unfocused
i tryed provider too but it's same. how can i fix this?
here's my code
void _changeButtonColor(int value) {✅✅✅✅
if (value == 0) {
setState(() => _isTimeFilled = false);
} else {
setState(() => _isTimeFilled = true);
}
}
TextFormField TimeTextFormField() {
return TextFormField(
focusNode: timeFocusNode,
autofocus: true,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
onChanged: (value) {
_changeButtonColor(value.length);✅✅✅✅
},
RaisedButton(
focusColor: Colors.white,
splashColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
onPressed: () {},
color: _isTimeFilled ? Colors.greenAccent : Colors.grey, ✅✅✅✅
textColor: Colors.white,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: double.infinity, child: Icon(Icons.check)),
),
),
),