class TransferForm extends StatelessWidget {
final TextEditingController _accountNumberController =
new TextEditingController();
final TextEditingController _amountController = new TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Form')),
body: Column(
children: [
Editor(
controller: _accountNumberController,
inputLabel: 'Account Number',
labelHintText: '0000'),
Editor(
controller: _amountController,
inputLabel: 'Amount',
labelHintText: '0.00',
icon: Icons.monetization_on),
RaisedButton(
onPressed: () => _createTransfer(),
child: Text('Confirm'),
),
],
),
);
}
void _createTransfer() {
final int accountNumber = int.tryParse(_accountNumberController.text);
final double transferAmount = double.tryParse(_amountController.text);
if (accountNumber != null && transferAmount != null) {
final newTransfer = Transfer(accountNumber, transferAmount);
debugPrint('$newTransfer');
}
}
}
O onPressed do RaisedButton chama o método __createTransfer(), mas não passa as 2 variáveis como parâmetro. Como o método tem acesso á _accountNumberController e _amountController?