Closed
Description
If I start app without Internet, I dont get the status update that there is no update, but if I connect to internet and then disable again, it gives the update
Code
Composable
val isConnected by component.isConnected.collectAsState()
LaunchedEffect(isConnected) {
if (isConnected) {
snackBarHostState.currentSnackbarData?.dismiss()
return@LaunchedEffect
}
MedialSnackBarVisuals(
message = "No Internet Connection",
snackBarType = SnackBarType.Default,
duration = SnackbarDuration.Indefinite
).also { snackBarHostState.showSnackbar(it) }
}
Component
val isConnected = connectivity.statusUpdates
.mapLatest { it.isConnected }
.toStateFlow(componentScope, true)
init {
doOnResume { networkHelper.startUpdates() }
doOnPause { networkHelper.stopUpdates() }
}
I have also tried using the compose-device
dependency, but that too does not work
The connectivity status has value null