When doing a HTTP request
in Flutter I don’t get any Exception
like SocketException
when WiFi is on however there’s truly no web, quite it waits very long time till I get the outlined TimeoutException
. Additionally this situation seems when there’s community connection to start with however immediately the connection drops.
How do I make it that it immediately provides an exception at any time when community points happen?
This my present code:
strive {
await http
.get(url, headers: headers)
.timeout(const Period(seconds: 20));
} on SocketException catch (e, st) {
debugPrint('SocketException. Appears to be no web out there');
debugPrint(e.toString());
debugPrint('OS Errorcode: ${e.osError?.errorCode.toString()}');
} catch (e, st) {
debugPrint('Unknown error occur in `tryAndHandle`:');
}