diff --git a/packages/better_networking/lib/models/http_request_model.dart b/packages/better_networking/lib/models/http_request_model.dart index cc2d7411..2d915cfa 100644 --- a/packages/better_networking/lib/models/http_request_model.dart +++ b/packages/better_networking/lib/models/http_request_model.dart @@ -13,10 +13,7 @@ part 'http_request_model.g.dart'; class HttpRequestModel with _$HttpRequestModel { const HttpRequestModel._(); - @JsonSerializable( - explicitToJson: true, - anyMap: true, - ) + @JsonSerializable(explicitToJson: true, anyMap: true) const factory HttpRequestModel({ @Default(HTTPVerb.get) HTTPVerb method, @Default("") String url, diff --git a/packages/better_networking/lib/models/http_request_model.freezed.dart b/packages/better_networking/lib/models/http_request_model.freezed.dart index 38cd0132..864ae7e0 100644 --- a/packages/better_networking/lib/models/http_request_model.freezed.dart +++ b/packages/better_networking/lib/models/http_request_model.freezed.dart @@ -12,7 +12,8 @@ part of 'http_request_model.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); HttpRequestModel _$HttpRequestModelFromJson(Map json) { return _HttpRequestModel.fromJson(json); @@ -44,20 +45,22 @@ mixin _$HttpRequestModel { /// @nodoc abstract class $HttpRequestModelCopyWith<$Res> { factory $HttpRequestModelCopyWith( - HttpRequestModel value, $Res Function(HttpRequestModel) then) = - _$HttpRequestModelCopyWithImpl<$Res, HttpRequestModel>; + HttpRequestModel value, + $Res Function(HttpRequestModel) then, + ) = _$HttpRequestModelCopyWithImpl<$Res, HttpRequestModel>; @useResult - $Res call( - {HTTPVerb method, - String url, - List? headers, - List? params, - List? isHeaderEnabledList, - List? isParamEnabledList, - ContentType bodyContentType, - String? body, - String? query, - List? formData}); + $Res call({ + HTTPVerb method, + String url, + List? headers, + List? params, + List? isHeaderEnabledList, + List? isParamEnabledList, + ContentType bodyContentType, + String? body, + String? query, + List? formData, + }); } /// @nodoc @@ -86,79 +89,85 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel> Object? query = freezed, Object? formData = freezed, }) { - return _then(_value.copyWith( - method: null == method - ? _value.method - : method // ignore: cast_nullable_to_non_nullable - as HTTPVerb, - url: null == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String, - headers: freezed == headers - ? _value.headers - : headers // ignore: cast_nullable_to_non_nullable - as List?, - params: freezed == params - ? _value.params - : params // ignore: cast_nullable_to_non_nullable - as List?, - isHeaderEnabledList: freezed == isHeaderEnabledList - ? _value.isHeaderEnabledList - : isHeaderEnabledList // ignore: cast_nullable_to_non_nullable - as List?, - isParamEnabledList: freezed == isParamEnabledList - ? _value.isParamEnabledList - : isParamEnabledList // ignore: cast_nullable_to_non_nullable - as List?, - bodyContentType: null == bodyContentType - ? _value.bodyContentType - : bodyContentType // ignore: cast_nullable_to_non_nullable - as ContentType, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - query: freezed == query - ? _value.query - : query // ignore: cast_nullable_to_non_nullable - as String?, - formData: freezed == formData - ? _value.formData - : formData // ignore: cast_nullable_to_non_nullable - as List?, - ) as $Val); + return _then( + _value.copyWith( + method: null == method + ? _value.method + : method // ignore: cast_nullable_to_non_nullable + as HTTPVerb, + url: null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + headers: freezed == headers + ? _value.headers + : headers // ignore: cast_nullable_to_non_nullable + as List?, + params: freezed == params + ? _value.params + : params // ignore: cast_nullable_to_non_nullable + as List?, + isHeaderEnabledList: freezed == isHeaderEnabledList + ? _value.isHeaderEnabledList + : isHeaderEnabledList // ignore: cast_nullable_to_non_nullable + as List?, + isParamEnabledList: freezed == isParamEnabledList + ? _value.isParamEnabledList + : isParamEnabledList // ignore: cast_nullable_to_non_nullable + as List?, + bodyContentType: null == bodyContentType + ? _value.bodyContentType + : bodyContentType // ignore: cast_nullable_to_non_nullable + as ContentType, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as String?, + query: freezed == query + ? _value.query + : query // ignore: cast_nullable_to_non_nullable + as String?, + formData: freezed == formData + ? _value.formData + : formData // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); } } /// @nodoc abstract class _$$HttpRequestModelImplCopyWith<$Res> implements $HttpRequestModelCopyWith<$Res> { - factory _$$HttpRequestModelImplCopyWith(_$HttpRequestModelImpl value, - $Res Function(_$HttpRequestModelImpl) then) = - __$$HttpRequestModelImplCopyWithImpl<$Res>; + factory _$$HttpRequestModelImplCopyWith( + _$HttpRequestModelImpl value, + $Res Function(_$HttpRequestModelImpl) then, + ) = __$$HttpRequestModelImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {HTTPVerb method, - String url, - List? headers, - List? params, - List? isHeaderEnabledList, - List? isParamEnabledList, - ContentType bodyContentType, - String? body, - String? query, - List? formData}); + $Res call({ + HTTPVerb method, + String url, + List? headers, + List? params, + List? isHeaderEnabledList, + List? isParamEnabledList, + ContentType bodyContentType, + String? body, + String? query, + List? formData, + }); } /// @nodoc class __$$HttpRequestModelImplCopyWithImpl<$Res> extends _$HttpRequestModelCopyWithImpl<$Res, _$HttpRequestModelImpl> implements _$$HttpRequestModelImplCopyWith<$Res> { - __$$HttpRequestModelImplCopyWithImpl(_$HttpRequestModelImpl _value, - $Res Function(_$HttpRequestModelImpl) _then) - : super(_value, _then); + __$$HttpRequestModelImplCopyWithImpl( + _$HttpRequestModelImpl _value, + $Res Function(_$HttpRequestModelImpl) _then, + ) : super(_value, _then); /// Create a copy of HttpRequestModel /// with the given fields replaced by the non-null parameter values. @@ -176,48 +185,50 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res> Object? query = freezed, Object? formData = freezed, }) { - return _then(_$HttpRequestModelImpl( - method: null == method - ? _value.method - : method // ignore: cast_nullable_to_non_nullable - as HTTPVerb, - url: null == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String, - headers: freezed == headers - ? _value._headers - : headers // ignore: cast_nullable_to_non_nullable - as List?, - params: freezed == params - ? _value._params - : params // ignore: cast_nullable_to_non_nullable - as List?, - isHeaderEnabledList: freezed == isHeaderEnabledList - ? _value._isHeaderEnabledList - : isHeaderEnabledList // ignore: cast_nullable_to_non_nullable - as List?, - isParamEnabledList: freezed == isParamEnabledList - ? _value._isParamEnabledList - : isParamEnabledList // ignore: cast_nullable_to_non_nullable - as List?, - bodyContentType: null == bodyContentType - ? _value.bodyContentType - : bodyContentType // ignore: cast_nullable_to_non_nullable - as ContentType, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - query: freezed == query - ? _value.query - : query // ignore: cast_nullable_to_non_nullable - as String?, - formData: freezed == formData - ? _value._formData - : formData // ignore: cast_nullable_to_non_nullable - as List?, - )); + return _then( + _$HttpRequestModelImpl( + method: null == method + ? _value.method + : method // ignore: cast_nullable_to_non_nullable + as HTTPVerb, + url: null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + headers: freezed == headers + ? _value._headers + : headers // ignore: cast_nullable_to_non_nullable + as List?, + params: freezed == params + ? _value._params + : params // ignore: cast_nullable_to_non_nullable + as List?, + isHeaderEnabledList: freezed == isHeaderEnabledList + ? _value._isHeaderEnabledList + : isHeaderEnabledList // ignore: cast_nullable_to_non_nullable + as List?, + isParamEnabledList: freezed == isParamEnabledList + ? _value._isParamEnabledList + : isParamEnabledList // ignore: cast_nullable_to_non_nullable + as List?, + bodyContentType: null == bodyContentType + ? _value.bodyContentType + : bodyContentType // ignore: cast_nullable_to_non_nullable + as ContentType, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as String?, + query: freezed == query + ? _value.query + : query // ignore: cast_nullable_to_non_nullable + as String?, + formData: freezed == formData + ? _value._formData + : formData // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); } } @@ -225,23 +236,23 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res> @JsonSerializable(explicitToJson: true, anyMap: true) class _$HttpRequestModelImpl extends _HttpRequestModel { - const _$HttpRequestModelImpl( - {this.method = HTTPVerb.get, - this.url = "", - final List? headers, - final List? params, - final List? isHeaderEnabledList, - final List? isParamEnabledList, - this.bodyContentType = ContentType.json, - this.body, - this.query, - final List? formData}) - : _headers = headers, - _params = params, - _isHeaderEnabledList = isHeaderEnabledList, - _isParamEnabledList = isParamEnabledList, - _formData = formData, - super._(); + const _$HttpRequestModelImpl({ + this.method = HTTPVerb.get, + this.url = "", + final List? headers, + final List? params, + final List? isHeaderEnabledList, + final List? isParamEnabledList, + this.bodyContentType = ContentType.json, + this.body, + this.query, + final List? formData, + }) : _headers = headers, + _params = params, + _isHeaderEnabledList = isHeaderEnabledList, + _isParamEnabledList = isParamEnabledList, + _formData = formData, + super._(); factory _$HttpRequestModelImpl.fromJson(Map json) => _$$HttpRequestModelImplFromJson(json); @@ -325,10 +336,14 @@ class _$HttpRequestModelImpl extends _HttpRequestModel { (identical(other.url, url) || other.url == url) && const DeepCollectionEquality().equals(other._headers, _headers) && const DeepCollectionEquality().equals(other._params, _params) && - const DeepCollectionEquality() - .equals(other._isHeaderEnabledList, _isHeaderEnabledList) && - const DeepCollectionEquality() - .equals(other._isParamEnabledList, _isParamEnabledList) && + const DeepCollectionEquality().equals( + other._isHeaderEnabledList, + _isHeaderEnabledList, + ) && + const DeepCollectionEquality().equals( + other._isParamEnabledList, + _isParamEnabledList, + ) && (identical(other.bodyContentType, bodyContentType) || other.bodyContentType == bodyContentType) && (identical(other.body, body) || other.body == body) && @@ -339,17 +354,18 @@ class _$HttpRequestModelImpl extends _HttpRequestModel { @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( - runtimeType, - method, - url, - const DeepCollectionEquality().hash(_headers), - const DeepCollectionEquality().hash(_params), - const DeepCollectionEquality().hash(_isHeaderEnabledList), - const DeepCollectionEquality().hash(_isParamEnabledList), - bodyContentType, - body, - query, - const DeepCollectionEquality().hash(_formData)); + runtimeType, + method, + url, + const DeepCollectionEquality().hash(_headers), + const DeepCollectionEquality().hash(_params), + const DeepCollectionEquality().hash(_isHeaderEnabledList), + const DeepCollectionEquality().hash(_isParamEnabledList), + bodyContentType, + body, + query, + const DeepCollectionEquality().hash(_formData), + ); /// Create a copy of HttpRequestModel /// with the given fields replaced by the non-null parameter values. @@ -358,28 +374,29 @@ class _$HttpRequestModelImpl extends _HttpRequestModel { @pragma('vm:prefer-inline') _$$HttpRequestModelImplCopyWith<_$HttpRequestModelImpl> get copyWith => __$$HttpRequestModelImplCopyWithImpl<_$HttpRequestModelImpl>( - this, _$identity); + this, + _$identity, + ); @override Map toJson() { - return _$$HttpRequestModelImplToJson( - this, - ); + return _$$HttpRequestModelImplToJson(this); } } abstract class _HttpRequestModel extends HttpRequestModel { - const factory _HttpRequestModel( - {final HTTPVerb method, - final String url, - final List? headers, - final List? params, - final List? isHeaderEnabledList, - final List? isParamEnabledList, - final ContentType bodyContentType, - final String? body, - final String? query, - final List? formData}) = _$HttpRequestModelImpl; + const factory _HttpRequestModel({ + final HTTPVerb method, + final String url, + final List? headers, + final List? params, + final List? isHeaderEnabledList, + final List? isParamEnabledList, + final ContentType bodyContentType, + final String? body, + final String? query, + final List? formData, + }) = _$HttpRequestModelImpl; const _HttpRequestModel._() : super._(); factory _HttpRequestModel.fromJson(Map json) = diff --git a/packages/better_networking/lib/models/http_request_model.g.dart b/packages/better_networking/lib/models/http_request_model.g.dart index 13795ded..bd024acc 100644 --- a/packages/better_networking/lib/models/http_request_model.g.dart +++ b/packages/better_networking/lib/models/http_request_model.g.dart @@ -6,50 +6,48 @@ part of 'http_request_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$HttpRequestModelImpl _$$HttpRequestModelImplFromJson(Map json) => - _$HttpRequestModelImpl( - method: $enumDecodeNullable(_$HTTPVerbEnumMap, json['method']) ?? - HTTPVerb.get, - url: json['url'] as String? ?? "", - headers: (json['headers'] as List?) - ?.map((e) => - NameValueModel.fromJson(Map.from(e as Map))) - .toList(), - params: (json['params'] as List?) - ?.map((e) => - NameValueModel.fromJson(Map.from(e as Map))) - .toList(), - isHeaderEnabledList: (json['isHeaderEnabledList'] as List?) - ?.map((e) => e as bool) - .toList(), - isParamEnabledList: (json['isParamEnabledList'] as List?) - ?.map((e) => e as bool) - .toList(), - bodyContentType: - $enumDecodeNullable(_$ContentTypeEnumMap, json['bodyContentType']) ?? - ContentType.json, - body: json['body'] as String?, - query: json['query'] as String?, - formData: (json['formData'] as List?) - ?.map((e) => - FormDataModel.fromJson(Map.from(e as Map))) - .toList(), - ); +_$HttpRequestModelImpl _$$HttpRequestModelImplFromJson( + Map json, +) => _$HttpRequestModelImpl( + method: + $enumDecodeNullable(_$HTTPVerbEnumMap, json['method']) ?? HTTPVerb.get, + url: json['url'] as String? ?? "", + headers: (json['headers'] as List?) + ?.map((e) => NameValueModel.fromJson(Map.from(e as Map))) + .toList(), + params: (json['params'] as List?) + ?.map((e) => NameValueModel.fromJson(Map.from(e as Map))) + .toList(), + isHeaderEnabledList: (json['isHeaderEnabledList'] as List?) + ?.map((e) => e as bool) + .toList(), + isParamEnabledList: (json['isParamEnabledList'] as List?) + ?.map((e) => e as bool) + .toList(), + bodyContentType: + $enumDecodeNullable(_$ContentTypeEnumMap, json['bodyContentType']) ?? + ContentType.json, + body: json['body'] as String?, + query: json['query'] as String?, + formData: (json['formData'] as List?) + ?.map((e) => FormDataModel.fromJson(Map.from(e as Map))) + .toList(), +); Map _$$HttpRequestModelImplToJson( - _$HttpRequestModelImpl instance) => - { - 'method': _$HTTPVerbEnumMap[instance.method]!, - 'url': instance.url, - 'headers': instance.headers?.map((e) => e.toJson()).toList(), - 'params': instance.params?.map((e) => e.toJson()).toList(), - 'isHeaderEnabledList': instance.isHeaderEnabledList, - 'isParamEnabledList': instance.isParamEnabledList, - 'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!, - 'body': instance.body, - 'query': instance.query, - 'formData': instance.formData?.map((e) => e.toJson()).toList(), - }; + _$HttpRequestModelImpl instance, +) => { + 'method': _$HTTPVerbEnumMap[instance.method]!, + 'url': instance.url, + 'headers': instance.headers?.map((e) => e.toJson()).toList(), + 'params': instance.params?.map((e) => e.toJson()).toList(), + 'isHeaderEnabledList': instance.isHeaderEnabledList, + 'isParamEnabledList': instance.isParamEnabledList, + 'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!, + 'body': instance.body, + 'query': instance.query, + 'formData': instance.formData?.map((e) => e.toJson()).toList(), +}; const _$HTTPVerbEnumMap = { HTTPVerb.get: 'get', diff --git a/packages/better_networking/lib/models/http_response_model.dart b/packages/better_networking/lib/models/http_response_model.dart index 316e5b79..b3effc76 100644 --- a/packages/better_networking/lib/models/http_response_model.dart +++ b/packages/better_networking/lib/models/http_response_model.dart @@ -44,10 +44,7 @@ class DurationConverter implements JsonConverter { class HttpResponseModel with _$HttpResponseModel { const HttpResponseModel._(); - @JsonSerializable( - explicitToJson: true, - anyMap: true, - ) + @JsonSerializable(explicitToJson: true, anyMap: true) const factory HttpResponseModel({ int? statusCode, Map? headers, @@ -65,9 +62,9 @@ class HttpResponseModel with _$HttpResponseModel { MediaType? get mediaType => getMediaTypeFromHeaders(headers); HttpResponseModel fromResponse({required Response response, Duration? time}) { - final responseHeaders = mergeMaps( - {HttpHeaders.contentLengthHeader: response.contentLength.toString()}, - response.headers); + final responseHeaders = mergeMaps({ + HttpHeaders.contentLengthHeader: response.contentLength.toString(), + }, response.headers); MediaType? mediaType = getMediaTypeFromHeaders(responseHeaders); final body = (mediaType?.subtype == kSubTypeJson) ? utf8.decode(response.bodyBytes) diff --git a/packages/better_networking/lib/models/http_response_model.freezed.dart b/packages/better_networking/lib/models/http_response_model.freezed.dart index 45071986..b4474f4e 100644 --- a/packages/better_networking/lib/models/http_response_model.freezed.dart +++ b/packages/better_networking/lib/models/http_response_model.freezed.dart @@ -12,7 +12,8 @@ part of 'http_response_model.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); HttpResponseModel _$HttpResponseModelFromJson(Map json) { return _HttpResponseModel.fromJson(json); @@ -43,17 +44,19 @@ mixin _$HttpResponseModel { /// @nodoc abstract class $HttpResponseModelCopyWith<$Res> { factory $HttpResponseModelCopyWith( - HttpResponseModel value, $Res Function(HttpResponseModel) then) = - _$HttpResponseModelCopyWithImpl<$Res, HttpResponseModel>; + HttpResponseModel value, + $Res Function(HttpResponseModel) then, + ) = _$HttpResponseModelCopyWithImpl<$Res, HttpResponseModel>; @useResult - $Res call( - {int? statusCode, - Map? headers, - Map? requestHeaders, - String? body, - String? formattedBody, - @Uint8ListConverter() Uint8List? bodyBytes, - @DurationConverter() Duration? time}); + $Res call({ + int? statusCode, + Map? headers, + Map? requestHeaders, + String? body, + String? formattedBody, + @Uint8ListConverter() Uint8List? bodyBytes, + @DurationConverter() Duration? time, + }); } /// @nodoc @@ -79,64 +82,70 @@ class _$HttpResponseModelCopyWithImpl<$Res, $Val extends HttpResponseModel> Object? bodyBytes = freezed, Object? time = freezed, }) { - return _then(_value.copyWith( - statusCode: freezed == statusCode - ? _value.statusCode - : statusCode // ignore: cast_nullable_to_non_nullable - as int?, - headers: freezed == headers - ? _value.headers - : headers // ignore: cast_nullable_to_non_nullable - as Map?, - requestHeaders: freezed == requestHeaders - ? _value.requestHeaders - : requestHeaders // ignore: cast_nullable_to_non_nullable - as Map?, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - formattedBody: freezed == formattedBody - ? _value.formattedBody - : formattedBody // ignore: cast_nullable_to_non_nullable - as String?, - bodyBytes: freezed == bodyBytes - ? _value.bodyBytes - : bodyBytes // ignore: cast_nullable_to_non_nullable - as Uint8List?, - time: freezed == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as Duration?, - ) as $Val); + return _then( + _value.copyWith( + statusCode: freezed == statusCode + ? _value.statusCode + : statusCode // ignore: cast_nullable_to_non_nullable + as int?, + headers: freezed == headers + ? _value.headers + : headers // ignore: cast_nullable_to_non_nullable + as Map?, + requestHeaders: freezed == requestHeaders + ? _value.requestHeaders + : requestHeaders // ignore: cast_nullable_to_non_nullable + as Map?, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as String?, + formattedBody: freezed == formattedBody + ? _value.formattedBody + : formattedBody // ignore: cast_nullable_to_non_nullable + as String?, + bodyBytes: freezed == bodyBytes + ? _value.bodyBytes + : bodyBytes // ignore: cast_nullable_to_non_nullable + as Uint8List?, + time: freezed == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as Duration?, + ) + as $Val, + ); } } /// @nodoc abstract class _$$HttpResponseModelImplCopyWith<$Res> implements $HttpResponseModelCopyWith<$Res> { - factory _$$HttpResponseModelImplCopyWith(_$HttpResponseModelImpl value, - $Res Function(_$HttpResponseModelImpl) then) = - __$$HttpResponseModelImplCopyWithImpl<$Res>; + factory _$$HttpResponseModelImplCopyWith( + _$HttpResponseModelImpl value, + $Res Function(_$HttpResponseModelImpl) then, + ) = __$$HttpResponseModelImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {int? statusCode, - Map? headers, - Map? requestHeaders, - String? body, - String? formattedBody, - @Uint8ListConverter() Uint8List? bodyBytes, - @DurationConverter() Duration? time}); + $Res call({ + int? statusCode, + Map? headers, + Map? requestHeaders, + String? body, + String? formattedBody, + @Uint8ListConverter() Uint8List? bodyBytes, + @DurationConverter() Duration? time, + }); } /// @nodoc class __$$HttpResponseModelImplCopyWithImpl<$Res> extends _$HttpResponseModelCopyWithImpl<$Res, _$HttpResponseModelImpl> implements _$$HttpResponseModelImplCopyWith<$Res> { - __$$HttpResponseModelImplCopyWithImpl(_$HttpResponseModelImpl _value, - $Res Function(_$HttpResponseModelImpl) _then) - : super(_value, _then); + __$$HttpResponseModelImplCopyWithImpl( + _$HttpResponseModelImpl _value, + $Res Function(_$HttpResponseModelImpl) _then, + ) : super(_value, _then); /// Create a copy of HttpResponseModel /// with the given fields replaced by the non-null parameter values. @@ -151,36 +160,38 @@ class __$$HttpResponseModelImplCopyWithImpl<$Res> Object? bodyBytes = freezed, Object? time = freezed, }) { - return _then(_$HttpResponseModelImpl( - statusCode: freezed == statusCode - ? _value.statusCode - : statusCode // ignore: cast_nullable_to_non_nullable - as int?, - headers: freezed == headers - ? _value._headers - : headers // ignore: cast_nullable_to_non_nullable - as Map?, - requestHeaders: freezed == requestHeaders - ? _value._requestHeaders - : requestHeaders // ignore: cast_nullable_to_non_nullable - as Map?, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - formattedBody: freezed == formattedBody - ? _value.formattedBody - : formattedBody // ignore: cast_nullable_to_non_nullable - as String?, - bodyBytes: freezed == bodyBytes - ? _value.bodyBytes - : bodyBytes // ignore: cast_nullable_to_non_nullable - as Uint8List?, - time: freezed == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as Duration?, - )); + return _then( + _$HttpResponseModelImpl( + statusCode: freezed == statusCode + ? _value.statusCode + : statusCode // ignore: cast_nullable_to_non_nullable + as int?, + headers: freezed == headers + ? _value._headers + : headers // ignore: cast_nullable_to_non_nullable + as Map?, + requestHeaders: freezed == requestHeaders + ? _value._requestHeaders + : requestHeaders // ignore: cast_nullable_to_non_nullable + as Map?, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as String?, + formattedBody: freezed == formattedBody + ? _value.formattedBody + : formattedBody // ignore: cast_nullable_to_non_nullable + as String?, + bodyBytes: freezed == bodyBytes + ? _value.bodyBytes + : bodyBytes // ignore: cast_nullable_to_non_nullable + as Uint8List?, + time: freezed == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as Duration?, + ), + ); } } @@ -188,17 +199,17 @@ class __$$HttpResponseModelImplCopyWithImpl<$Res> @JsonSerializable(explicitToJson: true, anyMap: true) class _$HttpResponseModelImpl extends _HttpResponseModel { - const _$HttpResponseModelImpl( - {this.statusCode, - final Map? headers, - final Map? requestHeaders, - this.body, - this.formattedBody, - @Uint8ListConverter() this.bodyBytes, - @DurationConverter() this.time}) - : _headers = headers, - _requestHeaders = requestHeaders, - super._(); + const _$HttpResponseModelImpl({ + this.statusCode, + final Map? headers, + final Map? requestHeaders, + this.body, + this.formattedBody, + @Uint8ListConverter() this.bodyBytes, + @DurationConverter() this.time, + }) : _headers = headers, + _requestHeaders = requestHeaders, + super._(); factory _$HttpResponseModelImpl.fromJson(Map json) => _$$HttpResponseModelImplFromJson(json); @@ -249,8 +260,10 @@ class _$HttpResponseModelImpl extends _HttpResponseModel { (identical(other.statusCode, statusCode) || other.statusCode == statusCode) && const DeepCollectionEquality().equals(other._headers, _headers) && - const DeepCollectionEquality() - .equals(other._requestHeaders, _requestHeaders) && + const DeepCollectionEquality().equals( + other._requestHeaders, + _requestHeaders, + ) && (identical(other.body, body) || other.body == body) && (identical(other.formattedBody, formattedBody) || other.formattedBody == formattedBody) && @@ -261,14 +274,15 @@ class _$HttpResponseModelImpl extends _HttpResponseModel { @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( - runtimeType, - statusCode, - const DeepCollectionEquality().hash(_headers), - const DeepCollectionEquality().hash(_requestHeaders), - body, - formattedBody, - const DeepCollectionEquality().hash(bodyBytes), - time); + runtimeType, + statusCode, + const DeepCollectionEquality().hash(_headers), + const DeepCollectionEquality().hash(_requestHeaders), + body, + formattedBody, + const DeepCollectionEquality().hash(bodyBytes), + time, + ); /// Create a copy of HttpResponseModel /// with the given fields replaced by the non-null parameter values. @@ -277,25 +291,26 @@ class _$HttpResponseModelImpl extends _HttpResponseModel { @pragma('vm:prefer-inline') _$$HttpResponseModelImplCopyWith<_$HttpResponseModelImpl> get copyWith => __$$HttpResponseModelImplCopyWithImpl<_$HttpResponseModelImpl>( - this, _$identity); + this, + _$identity, + ); @override Map toJson() { - return _$$HttpResponseModelImplToJson( - this, - ); + return _$$HttpResponseModelImplToJson(this); } } abstract class _HttpResponseModel extends HttpResponseModel { - const factory _HttpResponseModel( - {final int? statusCode, - final Map? headers, - final Map? requestHeaders, - final String? body, - final String? formattedBody, - @Uint8ListConverter() final Uint8List? bodyBytes, - @DurationConverter() final Duration? time}) = _$HttpResponseModelImpl; + const factory _HttpResponseModel({ + final int? statusCode, + final Map? headers, + final Map? requestHeaders, + final String? body, + final String? formattedBody, + @Uint8ListConverter() final Uint8List? bodyBytes, + @DurationConverter() final Duration? time, + }) = _$HttpResponseModelImpl; const _HttpResponseModel._() : super._(); factory _HttpResponseModel.fromJson(Map json) = diff --git a/packages/better_networking/lib/models/http_response_model.g.dart b/packages/better_networking/lib/models/http_response_model.g.dart index 186fd152..e197be09 100644 --- a/packages/better_networking/lib/models/http_response_model.g.dart +++ b/packages/better_networking/lib/models/http_response_model.g.dart @@ -17,19 +17,20 @@ _$HttpResponseModelImpl _$$HttpResponseModelImplFromJson(Map json) => ), body: json['body'] as String?, formattedBody: json['formattedBody'] as String?, - bodyBytes: - const Uint8ListConverter().fromJson(json['bodyBytes'] as List?), + bodyBytes: const Uint8ListConverter().fromJson( + json['bodyBytes'] as List?, + ), time: const DurationConverter().fromJson((json['time'] as num?)?.toInt()), ); Map _$$HttpResponseModelImplToJson( - _$HttpResponseModelImpl instance) => - { - 'statusCode': instance.statusCode, - 'headers': instance.headers, - 'requestHeaders': instance.requestHeaders, - 'body': instance.body, - 'formattedBody': instance.formattedBody, - 'bodyBytes': const Uint8ListConverter().toJson(instance.bodyBytes), - 'time': const DurationConverter().toJson(instance.time), - }; + _$HttpResponseModelImpl instance, +) => { + 'statusCode': instance.statusCode, + 'headers': instance.headers, + 'requestHeaders': instance.requestHeaders, + 'body': instance.body, + 'formattedBody': instance.formattedBody, + 'bodyBytes': const Uint8ListConverter().toJson(instance.bodyBytes), + 'time': const DurationConverter().toJson(instance.time), +}; diff --git a/packages/better_networking/pubspec.yaml b/packages/better_networking/pubspec.yaml index 8c860a68..074e7ef9 100644 --- a/packages/better_networking/pubspec.yaml +++ b/packages/better_networking/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: http: ^1.3.0 http_parser: ^4.1.2 json5: ^0.8.2 + json_annotation: ^4.9.0 seed: ^0.0.3 xml: ^6.3.0