buildParameters method
Implementation
Map<String, String?>? buildParameters(Map<String, String?>? parameters) {
var parametersMap = this.parametersMap;
var parametersStatic = this.parametersStatic;
var parametersProviders = this.parametersProviders;
if (parametersMap == null &&
parametersStatic == null &&
parametersProviders == null) return null;
parameters ??= <String, String?>{};
parametersMap ??= {};
parametersStatic ??= {};
parametersProviders ??= {};
if (parametersMap.isEmpty &&
parametersStatic.isEmpty &&
parametersProviders.isEmpty) return null;
var requestParameters = <String, String?>{};
if (parametersStatic.isNotEmpty) {
requestParameters.addAll(parametersStatic);
}
var processedKeys = <String>{};
for (var key in parametersMap.keys) {
var key2 = parametersMap[key];
if (key2 == null || key2.isEmpty || key2 == '*') key2 = key;
var value = parameters[key];
if (value != null) {
requestParameters[key2] = value;
processedKeys.add(key);
}
}
if (parametersMap['*'] == '*') {
for (var key in parameters.keys) {
if (!processedKeys.contains(key)) {
var value = parameters[key];
requestParameters[key] = value;
processedKeys.add(key);
}
}
}
for (var key in parametersProviders.keys) {
var provider = parametersProviders[key];
if (provider == null) continue;
if (!processedKeys.contains(key)) {
String? value;
try {
value = provider(key);
} catch (e, s) {
print(e);
print(s);
}
if (requestParameters.containsKey(key)) {
if (value != null) {
requestParameters[key] = value;
}
} else {
requestParameters[key] = value;
}
}
}
return requestParameters.isNotEmpty ? requestParameters : null;
}