Para fazer funcionar o método POST deve ser feito idem o GET deve fazer o parse da URI e depois passar o baseUrl e em seguida o headers e o Body.
Future<Transaction> save(Transaction transaction) async {
final Map<String, dynamic> transactionMap = {
'value' : transaction.value,
'contact' : {
'name' : transaction.contact.name,
'accountNumber' : transaction.contact.accountNumber,
}
};
final String transactionJson = jsonEncode(transactionMap);
final Response response = await client.post(Uri.parse(baseUrl), headers: {
'Content-type': 'application/json',
'password': '1000',
}, body: transactionJson
);
Map<String, dynamic> json = jsonDecode(response.body);
final Map<String, dynamic> contactJson = json['contact'];
return Transaction(
json['value'],
Contact(
0,
contactJson['name'],
contactJson['accountNumber'],
),
);
return transaction;
}
Fazendo isso o código já ira compilar.
✌️