aparece esse erro ai (E/flutter ( 7729): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value E/flutter ( 7729): #0 TransactionFormState.save (package:newbaytebankproject/lib/screens/transaction_form.dart:103:39)) alguém pode me ajudar é urgente.
class TransactionForm extends StatefulWidget {
final Contact contact;
TransactionForm(this.contact);
@override
_TransactionFormState createState() => _TransactionFormState();
}
class _TransactionFormState extends State<TransactionForm> {
final TextEditingController _valueController = TextEditingController();
final TransactionWebclient _webclient = TransactionWebclient();
final String transactionId = Uuid().v4();
@override
Widget build(BuildContext context) {
print ('transactioform id $transactionId');
return Scaffold(
appBar: AppBar(
title: const Text('New transaction'),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.contact.name,
style: const TextStyle(
fontSize: 24.0,
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Text(
widget.contact.accountNumber.toString(),
style: const TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: TextField(
controller: _valueController,
style: const TextStyle(fontSize: 24.0),
decoration: const InputDecoration(labelText: 'Value'),
keyboardType: const TextInputType.numberWithOptions(
decimal: true),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: SizedBox(
width: double.maxFinite,
child: ElevatedButton(
child: const Text('Transfer'),
onPressed: () {
final double? value =
double.tryParse(_valueController.text) ?? 0;
final transactionCreated =
Transaction(transactionId,value!, widget.contact,);
showDialog(
context: context,
builder: (contextDialog) {
return TransactionAuthDialog(
onConfirm: (String password) {
_save(transactionCreated, password, context);
},
);
});
},
),
),
)
],
),
),
),
);
}
void _save(Transaction transactionCreated,
String password,
BuildContext context,) async {
Transaction? transaction = await _send(
transactionCreated,
password,
context,
);
_showSuccessfulMessage(transaction!, context);
}
Future _showSuccessfulMessage(Transaction transaction,
BuildContext context) async {
if (transaction != null) {
await showDialog(
context: context,
builder: (contextDialog) {
return SuccessDialog('successful transaction');
});
Navigator.pop(context);
}
}
Future<Transaction?> _send(Transaction transactionCreated, String password,
BuildContext context) async {
final Transaction? transaction =
await _webclient.save(transactionCreated, password).catchError((e) {
_showFailureMessage(context, message: e.message);
}, test: (e) => e is HttpException).catchError((e) {
_showFailureMessage(
context, message: 'timeout submitting the transaction');
}, test: (e) => e is TimeoutException).catchError((e) {
_showFailureMessage(context);
});
return transaction;
}
void _showFailureMessage(BuildContext context,
{String message = 'Unknown error',
}) {
showDialog(
context: context,
builder: (contextDialog) {
return FailureDialog(message);
});
}
}