handlePopupRoutes method
Handles popup routes like dialogs and bottom sheets
Returns true if a popup was handled, false otherwise
Implementation
Future<bool> handlePopupRoutes({
Object? result,
}) async {
// Get the current route at the top of the navigator
Route? currentRoute;
navigatorKey.currentState!.popUntil((route) {
currentRoute = route;
return true;
});
// Handle the route based on its type
return switch (currentRoute) {
// If it's a popup route (dialog, bottom sheet, etc.), try to pop it
PopupRoute() => await navigatorKey.currentState!.maybePop(result),
// For any other route type, return false
_ => false,
};
}