go router fix

This commit is contained in:
mso7nueh
2024-06-11 05:13:30 +03:00
parent 647e9e9133
commit ddc908da57
32 changed files with 907 additions and 884 deletions

View File

@@ -1,28 +0,0 @@
import 'package:flutter/material.dart';
class NavigatorService {
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
static Future<dynamic> pushNamed(String routeName,
{dynamic arguments}) async {
return navigatorKey.currentState
?.pushNamed(routeName, arguments: arguments);
}
static void goBack() {
return navigatorKey.currentState?.pop();
}
static Future<dynamic> pushNamedAndRemoveUntil(String routeName,
{bool routePredicate = false, dynamic arguments}) async {
return navigatorKey.currentState?.pushNamedAndRemoveUntil(
routeName, (route) => routePredicate,
arguments: arguments);
}
static Future<dynamic> popAndPushNamed(String routeName,
{dynamic arguments}) async {
return navigatorKey.currentState
?.popAndPushNamed(routeName, arguments: arguments);
}
}

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_router.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -5,13 +6,11 @@ class ProgressDialogUtils {
static bool isProgressVisible = false;
///common method for showing progress dialog
static void showProgressDialog(
{BuildContext? context, isCancellable = false}) async {
if (!isProgressVisible &&
NavigatorService.navigatorKey.currentState?.overlay?.context != null) {
static void showProgressDialog({BuildContext? context, isCancellable = false}) async {
if (!isProgressVisible && AppRouter.navigatorKey.currentState?.overlay?.context != null) {
showDialog(
barrierDismissible: isCancellable,
context: NavigatorService.navigatorKey.currentState!.overlay!.context,
context: AppRouter.navigatorKey.currentState!.overlay!.context,
builder: (BuildContext context) {
return Center(
child: CircularProgressIndicator.adaptive(
@@ -28,9 +27,7 @@ class ProgressDialogUtils {
///common method for hiding progress dialog
static void hideProgressDialog() {
if (isProgressVisible)
Navigator.pop(
NavigatorService.navigatorKey.currentState!.overlay!.context);
if (isProgressVisible) Navigator.pop(AppRouter.navigatorKey.currentState!.overlay!.context);
isProgressVisible = false;
}
}