I have this widget:
TextInputSettingsTile(
title: 'Valor actual',
settingKey: 'current_value',
initialValue: '0',
keyboardType: isNumber
? TextInputType.numberWithOptions()
: TextInputType.text,
inputFormatters: [
isNumber
? FilteringTextInputFormatter.digitsOnly
: FilteringTextInputFormatter.singleLineFormatter,
],
onChange: (value) {
if (isNumber) {
Settings.setValue(
'current_int_value',
int.tryParse(value) ?? 0,
);
} else {
Settings.setValue('current_string_value', value);
}
},
),
This is similar to TextFormField and, in fact, it has almost the same properties.
Please, look at this fragment:
keyboardType: isNumber
? TextInputType.numberWithOptions()
: TextInputType.text,
inputFormatters: [
isNumber
? FilteringTextInputFormatter.digitsOnly
: FilteringTextInputFormatter.singleLineFormatter,
],
where isNumber is a boolean variable declared and assigned somewhere else.
When isNumber is true, I want to allow only digits to be inputted, otherwise, any character.
The problem is that it does not work when isNumber value changes. In order to make it work, I need to quit and restart the application.
Any himt, please?