-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from cb-amutha/impro/cache_receipt_retry
Implemented retry mechanism for validate receipt
- Loading branch information
Showing
22 changed files
with
636 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
import 'package:connectivity_plus/connectivity_plus.dart'; | ||
|
||
class NetworkConnectivity { | ||
NetworkConnectivity._(); | ||
static final _instance = NetworkConnectivity._(); | ||
static NetworkConnectivity get instance => _instance; | ||
final _networkConnectivity = Connectivity(); | ||
final _controller = StreamController.broadcast(); | ||
Stream get myStream => _controller.stream; | ||
|
||
Future<void> initialise() async { | ||
_networkConnectivity.onConnectivityChanged.listen(_checkStatus); | ||
} | ||
|
||
Future<void> _checkStatus(ConnectivityResult result) async { | ||
var isOnline = false; | ||
try { | ||
final result = await InternetAddress.lookup('example.com'); | ||
isOnline = result.isNotEmpty && result[0].rawAddress.isNotEmpty; | ||
} on SocketException catch (_) { | ||
isOnline = false; | ||
} | ||
_controller.sink.add({result: isOnline}); | ||
} | ||
void disposeStream() => _controller.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.