You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code makes three requests to 3 different addresses at the same time which is pretty data-consuming, isn't it better to wait for a request to finish, and if it's a failure, try the next?
` Future get hasConnection async {
final Completer result = Completer();
int length = addresses.length;
for (final AddressCheckOptions addressOptions in addresses) {
// ignore: unawaited_futures
isHostReachable(addressOptions).then(
(AddressCheckResult request) {
length -= 1;
if (!result.isCompleted) {
if (request.isSuccess) {
result.complete(true);
} else if (length == 0) {
result.complete(false);
}
}
},
);
}
return result.future;
}`
A small tweak to this function will do the trick.
Thank you.
The text was updated successfully, but these errors were encountered:
This package just attempts to establish a connection with the given servers, which should have very little overhead. How much data usage are you measuring?
The current code makes three requests to 3 different addresses at the same time which is pretty data-consuming, isn't it better to wait for a request to finish, and if it's a failure, try the next?
` Future get hasConnection async {
final Completer result = Completer();
int length = addresses.length;
}`
A small tweak to this function will do the trick.
Thank you.
The text was updated successfully, but these errors were encountered: