FormRequest constructor
FormRequest({
- TransportPlatform? transportPlatform,
Implementation
factory FormRequest({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 FormRequest 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.newFormRequest(transportPlatform);
} else if (transportPlatform != null) {
// Otherwise, return a real instance using the given transport platform.
return transportPlatform.newFormRequest();
} 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 FormRequest.
throw TransportPlatformMissing.httpRequestFailed('FormRequest');
}
}