Use local variables

This commit is contained in:
poka 2021-02-13 01:04:40 +01:00
parent db6aa150b5
commit 2d234e5a33
1 changed files with 9 additions and 9 deletions

View File

@ -36,10 +36,10 @@ class HomeProvider with ChangeNotifier {
int i = 0; int i = 0;
String _endpoint; String _endpoint;
int statusCode = 0; int _statusCode = 0;
final client = new HttpClient(); final _client = new HttpClient();
client.connectionTimeout = const Duration(milliseconds: 800); _client.connectionTimeout = const Duration(milliseconds: 800);
do { do {
i++; i++;
@ -55,25 +55,25 @@ class HomeProvider with ChangeNotifier {
} }
try { try {
final request = await client.postUrl(Uri.parse(_listEndpoints[i])); final request = await _client.postUrl(Uri.parse(_listEndpoints[i]));
final response = await request.close(); final response = await request.close();
_endpoint = _listEndpoints[i]; _endpoint = _listEndpoints[i];
statusCode = response.statusCode; _statusCode = response.statusCode;
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
print('This endpoint is timeout, next'); print('This endpoint is timeout, next');
statusCode = 50; _statusCode = 50;
continue; continue;
} on SocketException catch (_) { } on SocketException catch (_) {
print('This endpoint is a bad endpoint, next'); print('This endpoint is a bad endpoint, next');
statusCode = 70; _statusCode = 70;
continue; continue;
} on Exception { } on Exception {
print('Unknown error'); print('Unknown error');
statusCode = 60; _statusCode = 60;
continue; continue;
} }
} while (statusCode != 400); } while (_statusCode != 400);
print('ENDPOINT: ' + _endpoint); print('ENDPOINT: ' + _endpoint);
return _endpoint; return _endpoint;