I get an unhandled exception error at times, and at other times, it works just fine. Not sure what is causing this issue. What I understand from my limited understanding is that it sends a async request awaiting a response. And before the response is received, the connection is already closed by the server for some reason.
http.Response response = await http.post(Uri.parse(url), body: body);
How can I fix it?
Also, how can I catch and handle these issues for a better UI experience for the user? I tried using
FlutterError.onError
but didn't catch this error for some reason.
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Connection closed before full header was received
#0 IOClient.send
package:http/src/io_client.dart:90
<asynchronous suspension>
#1 BaseClient._sendUnstreamed
package:http/src/base_client.dart:93
<asynchronous suspension>
#2 _withClient
package:http/http.dart:164
<asynchronous suspension>
#3 _HomeScreenState.checkUser
package:project/home/home.dart:64
<asynchronous suspension>