navigateToNamed method

dynamic navigateToNamed(
  1. String routeName, {
  2. bool replace = false,
  3. Map<String, String>? params,
  4. Map<String, dynamic>? queryParams,
})

Implementation

navigateToNamed(
  String routeName, {
  bool replace = false,
  Map<String, String>? params,
  Map<String, dynamic>? queryParams,
}) {
  if (navigatorKey.currentContext != null) {
    if (replace) {
      if (params != null && queryParams != null) {
        navigatorKey.currentContext!.goNamed(
          routeName,
          params: params,
          queryParams: queryParams,
        );
      } else {
        if (params != null) {
          (navigatorKey.currentContext!).goNamed(
            routeName,
            params: params,
          );
        } else if (queryParams != null) {
          (navigatorKey.currentContext!).goNamed(
            routeName,
            queryParams: queryParams,
          );
        } else {
          navigatorKey.currentContext!.goNamed(
            routeName,
          );
        }
      }
    } else {
      if (params != null && queryParams != null) {
        (navigatorKey.currentContext!).goNamed(
          routeName,
          params: params,
          queryParams: queryParams,
        );
      } else {
        if (params != null) {
          (navigatorKey.currentContext!).goNamed(
            routeName,
            params: params,
          );
        } else if (queryParams != null) {
          (navigatorKey.currentContext!).goNamed(
            routeName,
            queryParams: queryParams,
          );
        } else {
          (navigatorKey.currentContext!).goNamed(
            routeName,
          );
        }
      }
    }
  }
}