Skip to content

Commit

Permalink
Convert to super params
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal committed Dec 20, 2023
1 parent 69f8bd1 commit 52abfb3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 73 deletions.
104 changes: 34 additions & 70 deletions dio/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,45 +122,27 @@ mixin OptionsMixin {
/// The base config for the Dio instance, used by [Dio.options].
class BaseOptions extends _RequestConfig with OptionsMixin {
BaseOptions({
String? method,
super.method,
Duration? connectTimeout,
Duration? receiveTimeout,
Duration? sendTimeout,
super.receiveTimeout,
super.sendTimeout,
String baseUrl = '',
Map<String, dynamic>? queryParameters,
Map<String, dynamic>? extra,
Map<String, dynamic>? headers,
bool preserveHeaderCase = false,
ResponseType? responseType = ResponseType.json,
String? contentType,
ValidateStatus? validateStatus,
bool? receiveDataWhenStatusError,
bool? followRedirects,
int? maxRedirects,
bool? persistentConnection,
RequestEncoder? requestEncoder,
ResponseDecoder? responseDecoder,
ListFormat? listFormat,
super.extra,
super.headers,
bool super.preserveHeaderCase = false,
super.responseType = ResponseType.json,
super.contentType,
super.validateStatus,
super.receiveDataWhenStatusError,
super.followRedirects,
super.maxRedirects,
super.persistentConnection,
super.requestEncoder,
super.responseDecoder,
super.listFormat,
}) : assert(connectTimeout == null || !connectTimeout.isNegative),
assert(baseUrl.isEmpty || Uri.parse(baseUrl).host.isNotEmpty),
super(
method: method,
receiveTimeout: receiveTimeout,
sendTimeout: sendTimeout,
extra: extra,
headers: headers,
preserveHeaderCase: preserveHeaderCase,
responseType: responseType,
contentType: contentType,
validateStatus: validateStatus,
receiveDataWhenStatusError: receiveDataWhenStatusError,
followRedirects: followRedirects,
maxRedirects: maxRedirects,
persistentConnection: persistentConnection,
requestEncoder: requestEncoder,
responseDecoder: responseDecoder,
listFormat: listFormat,
) {
assert(baseUrl.isEmpty || Uri.parse(baseUrl).host.isNotEmpty) {
this.queryParameters = queryParameters ?? {};
this.baseUrl = baseUrl;
this.connectTimeout = connectTimeout;
Expand Down Expand Up @@ -488,46 +470,28 @@ class RequestOptions extends _RequestConfig with OptionsMixin {
this.onReceiveProgress,
this.onSendProgress,
this.cancelToken,
String? method,
Duration? sendTimeout,
Duration? receiveTimeout,
super.method,
super.sendTimeout,
super.receiveTimeout,
Duration? connectTimeout,
Map<String, dynamic>? queryParameters,
String? baseUrl,
Map<String, dynamic>? extra,
Map<String, dynamic>? headers,
bool? preserveHeaderCase,
ResponseType? responseType,
String? contentType,
ValidateStatus? validateStatus,
bool? receiveDataWhenStatusError,
bool? followRedirects,
int? maxRedirects,
bool? persistentConnection,
RequestEncoder? requestEncoder,
ResponseDecoder? responseDecoder,
ListFormat? listFormat,
super.extra,
super.headers,
super.preserveHeaderCase,
super.responseType,
super.contentType,
super.validateStatus,
super.receiveDataWhenStatusError,
super.followRedirects,
super.maxRedirects,
super.persistentConnection,
super.requestEncoder,
super.responseDecoder,
super.listFormat,
bool? setRequestContentTypeWhenNoPayload,
StackTrace? sourceStackTrace,
}) : assert(connectTimeout == null || !connectTimeout.isNegative),
super(
method: method,
sendTimeout: sendTimeout,
receiveTimeout: receiveTimeout,
extra: extra,
headers: headers,
preserveHeaderCase: preserveHeaderCase,
responseType: responseType,
contentType: contentType,
validateStatus: validateStatus,
receiveDataWhenStatusError: receiveDataWhenStatusError,
followRedirects: followRedirects,
maxRedirects: maxRedirects,
persistentConnection: persistentConnection,
requestEncoder: requestEncoder,
responseDecoder: responseDecoder,
listFormat: listFormat,
) {
}) : assert(connectTimeout == null || !connectTimeout.isNegative) {
this.sourceStackTrace = sourceStackTrace ?? StackTrace.current;
this.queryParameters = queryParameters ?? {};
this.baseUrl = baseUrl ?? '';
Expand Down
2 changes: 1 addition & 1 deletion dio/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ final Matcher throwsDioExceptionConnectionError = throwsA(

/// A stream of chunks of bytes representing a single piece of data.
class ByteStream extends StreamView<List<int>> {
ByteStream(Stream<List<int>> stream) : super(stream);
ByteStream(super.stream);

/// Returns a single-subscription byte stream that will emit the given bytes
/// in a single chunk.
Expand Down
6 changes: 6 additions & 0 deletions dio_workspace.iml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<excludeFolder url="file://$MODULE_DIR$/dio/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/dio/.pub" />
<excludeFolder url="file://$MODULE_DIR$/dio/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/.pub" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/plugins/native_dio_adapter/example/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
Expand Down
2 changes: 1 addition & 1 deletion example_flutter_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title = ''}) : super(key: key);
MyHomePage({super.key, this.title = ''});

final String title;

Expand Down
2 changes: 1 addition & 1 deletion example_flutter_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.15.0 <4.0.0"
sdk: ">=2.19.0 <4.0.0"

dependencies:
flutter:
Expand Down

0 comments on commit 52abfb3

Please sign in to comment.