getArgsFromPath method Null safety

Map<String, String> getArgsFromPath(
  1. {required String route,
  2. required String path}

TODO: This could be extracted Extracts a Map<String,String> from a path


Map<String, String> getArgsFromPath({required String route, required String path}) {
  // Get path params
  List<String> paramList = [];
  final regExp = pathToRegExp(route, parameters: paramList);
  Map<String, String> pathMap = {};
  if (regExp.hasMatch(path)) {
    final match = regExp.matchAsPrefix(path)!;
    pathMap = extract(paramList, match);
  // Get queryString params
  Map<String, String> queryMap = Uri.parse(path).queryParameters;
  // Combine path and query args into one, the query args will override the path items with the same id
  final o = {...pathMap, ...queryMap};
  return o;