Request constructor
Request(})
Creates a new Request object.
If bodyMap
is specified, the content will be encoded as JSON, alongside
with the appropriate header.
Implementation
factory Request(
String method,
List<String> pathSegments, {
Map<String, dynamic>? bodyMap,
String? bodyText,
Map<String, String>? params,
}) {
if (bodyMap != null && bodyText != null) {
throw ArgumentError(
'Only one of "bodyMap" or "bodyText" must be specified.');
}
bodyText ??= bodyMap == null ? null : convert.json.encode(bodyMap);
final headers =
bodyText == null ? null : {'Content-Type': 'application/json'};
return Request._(method, pathSegments, bodyText, headers, params);
}