showBottomSheet method
Opens new bottom sheet
Implementation
Future<dynamic> showBottomSheet(
UIRoute<BottomSheetType> bottomSheet, {
bool? forceGlobal,
bool? dismissable,
bool? uniqueInStack,
Object? id,
NavigationRouteBuilder? customRouteBuilder,
}) async {
final bool global = _checkGlobalNavigatorNeeded(
forceGlobal ?? bottomSheet.defaultSettings.global,
);
final bottomSheetSettings = UIRouteSettings(
global: global,
uniqueInStack: uniqueInStack ?? bottomSheet.defaultSettings.uniqueInStack,
dismissable: dismissable ?? bottomSheet.defaultSettings.dismissable,
id: id,
name: bottomSheet.name.toString(),
customRouteBuilder:
customRouteBuilder ?? bottomSheet.defaultSettings.customRouteBuilder,
);
if (bottomSheetSettings.uniqueInStack &&
!navigationStack.checkUnique(
routeName: bottomSheet,
tab: currentTab,
global: true,
)) {
return;
}
final bottomSheetName = bottomSheet.name;
final navigator =
global ? bottomSheetDialogNavigatorKey : currentTabKeys[currentTab]!;
navigationStack.addRoute(
routeName: bottomSheetName,
tab: currentTab,
settings: bottomSheetSettings,
);
final bottomSheetToOpen = bottomSheet.child;
unawaited(onBottomSheetOpened(bottomSheetToOpen, bottomSheetSettings));
final routeBuilder =
bottomSheetSettings.customRouteBuilder ?? settings.routeBuilder;
// coverage:ignore-start
final stackLength = global
? navigationStack.globalNavigationStack.stack.length
: navigationStack.tabNavigationStack.stack[currentTab]!.length;
// coverage:ignore-end
final route = routeBuilder.buildBottomSheetRoute(
navigator: navigator,
dismissable: bottomSheetSettings.dismissable,
child: bottomSheetToOpen,
// coverage:ignore-start
onPop: () {
final currentStackLength = global
? navigationStack.globalNavigationStack.stack.length
: navigationStack.tabNavigationStack.stack[currentTab]!.length;
if (currentStackLength == stackLength) {
pop(onlyInternalStack: true);
}
},
// coverage:ignore-end
);
final result = await navigator.currentState?.push(route);
return result;
}