Skip to content
Snippets Groups Projects
Commit 2d234e5a authored by poka's avatar poka
Browse files

Use local variables

parent db6aa150
No related branches found
No related tags found
No related merge requests found
...@@ -36,10 +36,10 @@ class HomeProvider with ChangeNotifier { ...@@ -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 { ...@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment