getCacheKeyFromPath static method

String getCacheKeyFromPath(
  1. String? path,
  2. Map<String, dynamic> params,
  3. List<String> ignoreKeys
)

Implementation

static String getCacheKeyFromPath(String? path, Map<String, dynamic> params,List<String> ignoreKeys) {
  String cacheKey = "";
  if (!(TextUtil.isEmpty(path))) {
    cacheKey = cacheKey + MD5Util.generateMd5(path!);
  } else {
    throw Exception("请求地址不能为空!");
  }
  if (params.isNotEmpty) {
    final tempParams = Map.from(params);
    tempParams.removeWhere((key, value) => ignoreKeys.contains(key));
    String paramsStr = "";
    tempParams.forEach((key, value) {
      paramsStr = "$paramsStr$key$value";
    });
    cacheKey = cacheKey + MD5Util.generateMd5(paramsStr);
  }
  return cacheKey;
}