Skip to content

Commit 17184c2

Browse files
authored
Merge pull request #6 from h4fide/fix-dioexception
Fix DioException in website check
2 parents a836cae + 7e6bf2c commit 17184c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/service.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// This code is just example code to show how mimic app work
2-
// This code is not working and just for educational purpose
3-
41
import 'dart:async';
2+
import 'dart:io';
53
import 'dart:math';
64
import 'package:http/http.dart' as http;
75
import 'dart:convert';
@@ -59,6 +57,10 @@ class PlatformActivitySimulator {
5957
);
6058

6159
return response.statusCode == 200;
60+
} on SocketException catch (e) {
61+
print('SocketException: $e');
62+
if (attempt == 2) rethrow;
63+
await Future.delayed(Duration(seconds: pow(2, attempt).toInt()));
6264
} catch (e) {
6365
if (attempt == 2) rethrow;
6466
await Future.delayed(Duration(seconds: pow(2, attempt).toInt()));
@@ -108,4 +110,4 @@ void main() {
108110
Future.delayed(const Duration(minutes: 1), () {
109111
simulator.stop();
110112
});
111-
}
113+
}

0 commit comments

Comments
 (0)