getArguments method

Map<String, String> getArguments(
  1. String routeName
)

获取路由参数 routeName 路由名称

Implementation

Map<String, String> getArguments(String routeName) {
  if (routeName.isEmptyString) {
    return {};
  }
  var parse = RouteUriParse(routeName);
  var path = parse.withoutQueryPath;
  var routes = CloudRouteObserver.instance.getRoutes(path);
  if (routes.isEmptyList) {
    return {};
  }
  //默认取第一个参数
  Route route = routes.first;
  Map<String, String> _arguments = {};
  var arguments = route.settings.arguments;
  if (arguments is RouteUriParse) {
    RouteUriParse routerUrlParse = arguments;
    _arguments = routerUrlParse.queryParameters;
  } else if (arguments is LinkedHashMap<String, String>) {
    LinkedHashMap<String, String> map = arguments;
    map.forEach((key, value) {
      _arguments[key] = value;
    });
  }
  return _arguments;
}