import 'package:get/get.dart'; import 'package:flutter/material.dart'; /// navigator class HelpNav { /// clear all route static Future? offAllNamed( String newRouteName, { Map? arguments, RoutePredicate? predicate, String? tag, Map? parameters, }) { return Get.offAllNamed( newRouteName, arguments: arguments, predicate: predicate, parameters: {...?parameters}, ); } static Future? off(Widget page, {arguments, preventDuplicates}) { return Get.off( () => page, arguments: arguments, preventDuplicates: preventDuplicates ?? false, ); } static Future? offAll(Widget page, {arguments, preventDuplicates}) { return Get.offAll(() => page, arguments: arguments); } static Future? offNamed( String newRouteName, { arguments, preventDuplicates, }) { return Get.offNamed( newRouteName, arguments: arguments, preventDuplicates: preventDuplicates ?? true, ); } /// to name static Future? toNamed( String newRouteName, { arguments, String? tag, Map? parameters, }) { return Get.toNamed( newRouteName, arguments: arguments, parameters: {...?parameters}, ); } /// to route static Future? to(Widget page, {arguments, binding}) { return Get.to( () => page, arguments: arguments, binding: binding, preventDuplicates: false, ); } static void _until({String? routeName, T? result}) { if (result == null) { Get.back(result: result); return; } // Get.back(result: result); // if (routeName == null) { Get.back(result: result); return; } } /// back pre /// [result] static void back({T? result, String? routeName}) { _until(routeName: routeName, result: result); } /// show dialog static Future showDialog( Widget child, { bool barrierDismissible = false, }) { return Get.dialog( Center(child: child), barrierDismissible: barrierDismissible, ); } /// show bottom sheet static Future showBottom( Widget child, { Color? safeAreaColor, double? borderRadius, bool isDismissible = false, bool isScrollControlled = false, bool? enableDrag, }) { return Get.bottomSheet( child, isScrollControlled: isScrollControlled, enableDrag: enableDrag ?? true, isDismissible: isDismissible, ); } }