onConnectionLost method
override
Implementation
@override
void onConnectionLost() {
var theme = Theme.of(context);
if (!hasPushed) {
if (connectivityDisplayType == ConnectivityDisplayType.screen) {
unawaited(
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => PopScope(
canPop: false,
child: screen,
),
),
),
);
hasPushed = true;
return;
}
if (connectivityDisplayType == ConnectivityDisplayType.snackBar) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: theme.snackBarTheme.backgroundColor,
content: screen,
duration: const Duration(
days: 1,
),
),
);
hasPushed = true;
return;
}
if (connectivityDisplayType == ConnectivityDisplayType.popUp ||
connectivityDisplayType == ConnectivityDisplayType.popUpDismissible) {
var isDismissible =
connectivityDisplayType != ConnectivityDisplayType.popUp;
unawaited(
showDialog(
barrierDismissible: isDismissible,
context: context,
builder: (context) => PopScope(
canPop: isDismissible,
child: screen,
),
),
);
hasPushed = true;
return;
}
}
}