Skip to content

Instantly share code, notes, and snippets.

@berkanaslan
Created May 28, 2021 07:04
Show Gist options
  • Save berkanaslan/9b3273eecb07cbf10c5c88f19b183ebc to your computer and use it in GitHub Desktop.
Save berkanaslan/9b3273eecb07cbf10c5c88f19b183ebc to your computer and use it in GitHub Desktop.
Future<bool> onWillPop(BuildContext context) async {
final currentNavigatorState = currentScreen.navigatorState.currentState;
if (currentNavigatorState.canPop()) {
currentNavigatorState.pop();
return false;
} else {
if (currentTabIndex != FIRST_SCREEN) {
setTab(FIRST_SCREEN);
notifyListeners();
return false;
} else {
return await showDialog(
context: context,
builder: (context) => ExitAlertDialog(),
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment