prepareUri method
Prepare the final URI for making the request.
baseUri
: The URI which will be the base to which the other
URIs will connect to.
requestUri
: Contains all the extra parameters like the endpoints,
queries and so one which will be added to baseUri
to make the
final request.
Implementation
Uri prepareUri(Uri baseUri, Uri requestUri) => baseUri.replace(
scheme: requestUri.hasScheme ? requestUri.scheme : baseUri.scheme,
host: requestUri.host != '' ? requestUri.host : null,
path: requestUri.path != '' ? requestUri.path : null,
queryParameters: (baseUri.queryParameters.isNotEmpty ||
requestUri.queryParameters.isNotEmpty)
? <String, dynamic>{
if (baseUri.queryParameters.isNotEmpty)
...baseUri.queryParameters,
if (requestUri.queryParameters.isNotEmpty)
...requestUri.queryParameters
}
: null,
);