0
I created the following function:
void _dolarChanged(String text) {
if (text.isEmpty) {
_clearAll();
return;
}
final double dolar = double.parse(text);
realController.text = (dolar * this.dolar).toStringAsFixed(2);
euroController.text = (dolar * this.dolar / euro).toStringAsFixed(2);
}
To be used in a TextField
in the onChanged
within a widget, but the following error is occurring:
The argument type 'Function' can’t be Assigned to the Parameter type 'void Function()'
The call from the Widget:
buildTextField('Dolares', 'US\$ ', dolarController, _dolarChanged),
Widget buildTextField(
String label,
String prefix,
TextEditingController controller,
Function function,
) {
return TextField(
controller: controller,
decoration: InputDecoration(
labelText: label,
labelStyle: TextStyle(color: Colors.amber),
border: const OutlineInputBorder(),
prefixText: prefix,
),
style: TextStyle(
color: Colors.amber,
fontSize: 25,
),
onChanged: function,
keyboardType: TextInputType.number,
);
}
Has anyone been through this mistake or knows how to fix it?