paramsConverter function

String paramsConverter({
  1. required String path,
  2. required Map<String, String?> params,
})

Implementation

String paramsConverter(
    {required String path, required Map<String, String?> params}) {
  List<String> paths = path
      .split("/")
      .where((element) => element != "" && element[0] == ":")
      .toList();
  for (var param in paths) {
    path =
        path.replaceFirst(param, params[param.replaceFirst(":", "")] ?? param);
  }
  return path;
}