gotoPage method

void gotoPage(
  1. bool clearHistory,
  2. String? appId,
  3. String? pageId, {
  4. Map<String, dynamic>? parameters,
  5. String? errorString,
})

Implementation

void gotoPage(bool clearHistory, String? appId, String? pageId,
    {Map<String, dynamic>? parameters, String? errorString}) {
  if (appId == null) {
    throw Exception('Error: gotoPage(null)');
  }
  if (pageId != null) {
    if (navigatorKey.currentState != null) {
      if (clearHistory) {
        navigatorKey.currentState!.pushNamedAndRemoveUntil(
            RouterApi.pageRoute, (_) => false,
            arguments: Arguments('$appId/$pageId', parameters));
      } else {
        navigatorKey.currentState!.pushNamed(RouterApi.pageRoute,
            arguments: Arguments('$appId/$pageId', parameters));
      }
    } else {
      throw Exception(
          "Can't pushNamed page $appId/$pageId because navigatorKey.currentState is null");
    }
  } else {
    if (clearHistory) {
      navigatorKey.currentState!.pushNamedAndRemoveUntil(
          RouterApi.messageRoute, (_) => false,
          arguments: Arguments(appId, {'message': errorString}));
    } else {
      navigatorKey.currentState!.pushNamed(RouterApi.messageRoute,
          arguments: Arguments(appId, {'message': errorString}));
    }
  }
}