在发出带有Flutter的发布请求时收到此错误。
我所有的字段和参数都是正确的,并且与邮递员配合得很好。我已经尝试了所有我知道的东西,但是我一直收到这个异常。
请帮帮我
_InternalLinkedHashMap<String, dynamic>' has no instance getter 'body'.
Tried calling: body
代码
_createWallet() async{
Navigator.pop(context);
setState(() {
_loading = true;
});
try{
Map<String, dynamic> data = {
'user_id': _bloc.user.id.toString(),
'bvn': _bvn.text.toString(),
'account_number': _accountNo.text.toString(),
'bank_code': _bankCode.toString(),
};
var jsonResponse = null;
var response = await
http.post(ApiService.BASE_URL + "wallet/account/create",
headers: {'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': "Bearer " + _bloc.bearerToken},
body: json.encode(data));
jsonResponse = json.decode(response.body);
print(jsonResponse.body.toString());
if (response.statusCode == 200 || response.statusCode == 201) {
Navigator.pop(context);
if (jsonResponse != null) {
setState(() {
_loading = false;
isPurseCreated = true;
showSuccessMsg();
});
print(jsonResponse['message']);
} else {
showToast("An error occurred");
setState(() {
showToast("An error occurred");
_loading = false;
isPurseCreated = false;
});
}
} else {
setState(() {
showToast("An error occurred");
_loading = false;
isPurseCreated = false;
});
}
}catch(e){
print(e.toString());
}
}