Boa noite!
Depois da refatoração minha função save está com o seguinte erro:
The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type. Try adding either a return or a throw statement at the end.
Segue código:
Future<Transaction> save(Transaction transaction, String password) async {
final String transactionJson = jsonEncode(transaction.toJson());
final http.Response response = await client.post(
Uri.parse(baseURL),
headers: {"Content-type": "application/json", "password": password},
body: transactionJson,
);
if (response.statusCode == 200) {
return Transaction.fromJson(jsonDecode(response.body));
}
_throwHttpError(response.statusCode);
}
Alguém consegue me ajudar?