goto static method

dynamic goto(
  1. String routeName, {
  2. dynamic parameter,
})

Implementation

static dynamic goto(String routeName, {dynamic parameter}) {
  dynamic action = Route.routeMap[routeName];
  try{
    if (action != null) {
      if (action is Function) {
        if (parameter == null) {
          return action();
        } else
          return action(parameter);
      } else if (action is String) {
        List<String> li = action.split('@');
        if (li.length == 2) {
          String controllerName = li[0];
          String methodName = li[1];
          return doRouting(controllerName, methodName, parameter);
        }
      }
      throw NoActionFoundError(routeName, parameter);
    } else {
      throw NoRouteFoundError(routeName, parameter);
      // cupertino.Navigator.push(ctxt, launchErrorPage);
      // print('No action for this route');
    }
  } catch(e, st){
      // rethrow;
    if(e is NoActionFoundError){
      goto(KareeConstants.KAREE_ERROR_PATH, parameter: {
        #title: e.message,
        #stack: st,
        #env: [routeName, parameter],
        #errorCode: KareeErrorCode.NO_ROUTE_FOUND});
    }else if( e is NoRouteFoundError ){
      goto(KareeConstants.KAREE_ERROR_PATH, parameter: {
        #title: e.message,
        #stack: st,
        #env: [routeName, if(parameter != null)parameter],
        #errorCode: KareeErrorCode.NO_ROUTE_FOUND});

    }
  }
}