forked from prateekmedia/pstube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification for not connected to internet, fix video screen and …
…channel widget
- Loading branch information
1 parent
67b05e5
commit 9a9062e
Showing
18 changed files
with
572 additions
and
284 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:connectivity_plus/connectivity_plus.dart'; | ||
|
||
enum NetworkStatus { online, offline, restored } | ||
|
||
class InternetConnectivity { | ||
static final StreamController _networkController = StreamController<NetworkStatus>.broadcast(); | ||
|
||
static Stream<NetworkStatus> get networkStream => _networkController.stream as Stream<NetworkStatus>; | ||
|
||
static NetworkStatus _status = NetworkStatus.online; | ||
static NetworkStatus get status => _status; | ||
|
||
static void networkStatusService() async { | ||
Connectivity().onConnectivityChanged.listen((status) async { | ||
if (status != ConnectivityResult.none) { | ||
_networkController.add(NetworkStatus.restored); | ||
await Future.delayed(const Duration(seconds: 5)); | ||
if (status != ConnectivityResult.none) { | ||
_networkController.add(NetworkStatus.online); | ||
} | ||
} else { | ||
_networkController.add(NetworkStatus.offline); | ||
} | ||
}); | ||
_networkController.stream.listen((event) { | ||
_status = event; | ||
}); | ||
if (await Connectivity().checkConnectivity() == ConnectivityResult.none) { | ||
_networkController.add(NetworkStatus.offline); | ||
} | ||
} | ||
|
||
void dispose() { | ||
_networkController.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
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
Oops, something went wrong.