StreamedRequest constructor
StreamedRequest({
- TransportPlatform? transportPlatform,
Implementation
factory StreamedRequest({TransportPlatform? transportPlatform}) {
// If a transport platform is not explicitly given, fallback to the globally
// configured platform.
transportPlatform ??= globalTransportPlatform;
if (MockTransportsInternal.isInstalled) {
// If transports are mocked, return a mock-aware StreamedRequest instance.
// This mock-aware instance will be able to decide at the time of dispatch
// whether or not the mock logic should handle the request.
return MockAwareTransportPlatform.newStreamedRequest(transportPlatform);
} else if (transportPlatform != null) {
// Otherwise, return a real instance using the given transport platform.
return transportPlatform.newStreamedRequest();
} else {
// If transports are not mocked and a transport platform is not available
// (neither explicitly given nor configured globally), then we cannot
// successfully construct a StreamedRequest.
throw TransportPlatformMissing.httpRequestFailed('StreamedRequest');
}
}