How to show circular indicator on flutter chewie player on network loss
Solution 1:
You can use connectivity_plus package from pub.dev, and listen to the change in user's device connectivity.
@override
initState() {
super.initState();
subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
// Got a new connectivity status!
})
}
You can perform different operations whenever the device connectivity status changes. Like showing CircularProgressIndicator()
when status changes to ConnectivityResult.none and resume playing (hide indicator) when status changes to ConnectivityResult.wifi
or ConnectivityResult.mobile
.
Don't forget to dispose the subscription:
@override
void dispose() {
subscription.cancel();
super.dispose();
}