I keep getting 'Bad file descriptor' errors for Flutter on iOS production builds. According to Sentry, they come from the post request I am sending to the backend.
Code of post function:
static Future<dynamic> post(
String endPoint, {
Map<String, dynamic>? body,
}) async {
var uri = Uri.parse(_apiUrl + endPoint);
print('post: $uri');
print('body: $body');
http.Response response;
response = await http.post(
uri,
body: json.encode(body),
headers: {
'Content-type': 'application/json',
},
);
// Check response: throws exception if not successful
_checkResponse(response);
return json.decode(response.body);
}
static void _checkResponse(http.Response res) {
print('_checkResponse code: ${res.statusCode}');
if (res.statusCode != 200) {
var body = json.decode(res.body);
print('body of error is : ${body['error']}');
throw NetworkException(
ExceptionError.fromMap(body['error']),
statusCode: res.statusCode,
);
}
}