toParametersPattern static method

Map<String, String>? toParametersPattern(
  1. Object? parametersPattern
)

Implementation

static Map<String, String>? toParametersPattern(Object? parametersPattern) {
  if (parametersPattern == null) return null;
  if (parametersPattern is String) {
    return decodeQueryString(parametersPattern);
  } else if (parametersPattern is Map) {
    return HttpCall.toQueryParameters(parametersPattern);
  } else if (parametersPattern is List) {
    parametersPattern.removeWhere((e) => isEmptyObject(e));
    if (parametersPattern.isEmpty) return null;

    var parameters = toParametersPattern(parametersPattern.first) ?? {};
    var extraParameters = parametersPattern.sublist(1);

    for (var params in extraParameters) {
      var map = toParametersPattern(params);
      if (map != null) {
        parameters.addAll(map);
      }
    }

    return parameters;
  } else {
    return null;
  }
}