getParamsRaw method
a method that allows us to customize even complex params generations by default, we just return the params passed to the request here.
Implementation
Map<String, String> getParamsRaw(
[Map<String, String?> customParams = const {}]) {
final overwritingParams = {...(customParams), ...overwriteParams};
final returnParams = <String, String>{};
// add all parameters, that are not null to the return params
params?.forEach((key, value) {
if (value != null) {
returnParams[key] = value;
}
});
// now loop through params and overwrite or remove (if value is null) value
for (final key in overwritingParams.keys) {
if (overwritingParams[key] == null) {
if (returnParams.containsKey(key)) {
returnParams.remove(key);
}
} else {
returnParams[key] = overwritingParams[key]!;
}
}
return returnParams;
}