Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content type #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 48 additions & 34 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.36.4"
analyzer_plugin:
version: "0.39.4"
archive:
dependency: transitive
description:
name: analyzer_plugin
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "2.0.11"
args:
dependency: transitive
description:
Expand All @@ -28,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.4.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -42,7 +49,7 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.2"
build_config:
dependency: transitive
description:
Expand All @@ -56,14 +63,14 @@ packages:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.3"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
version: "1.3.3"
build_runner:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -91,14 +98,14 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "6.7.1"
version: "7.0.9"
built_value_generator:
dependency: "direct dev"
description:
name: built_value_generator
url: "https://pub.dartlang.org"
source: hosted
version: "6.7.1"
version: "7.0.9"
charcode:
dependency: transitive
description:
Expand All @@ -119,7 +126,7 @@ packages:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
version: "3.2.1"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -161,7 +168,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.9"
version: "1.3.3"
dio:
dependency: transitive
description:
Expand Down Expand Up @@ -200,13 +207,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
front_end:
dependency: transitive
description:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.19"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -249,6 +249,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
io:
dependency: transitive
description:
Expand All @@ -269,21 +276,14 @@ packages:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "3.0.1"
json_serializable:
dependency: transitive
description:
name: json_serializable
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.19"
version: "3.2.5"
logging:
dependency: transitive
description:
Expand All @@ -297,14 +297,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.5"
version: "0.12.6"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
version: "1.1.8"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -340,6 +340,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -407,7 +414,7 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.4+4"
version: "0.9.4+7"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -435,7 +442,7 @@ packages:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.19"
version: "0.0.20"
string_scanner:
dependency: transitive
description:
Expand All @@ -456,7 +463,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
version: "0.2.11"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -492,6 +499,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
yaml:
dependency: transitive
description:
Expand All @@ -500,5 +514,5 @@ packages:
source: hosted
version: "2.2.0"
sdks:
dart: ">2.4.0 <3.0.0"
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.5.0 <2.0.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dev_dependencies:
sdk: flutter

build_runner: ^1.0.0
built_value_generator: ^6.4.0
built_value_generator: ^7.0.9


flutter:
Expand Down
5 changes: 5 additions & 0 deletions lib/src/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class ApiClient {
bool isAuthorisedRequest,
bool validate,
ResponseType responseType = ResponseType.json,
String contentType = Headers.jsonContentType,
}) {
return _request(RequestParams<T>(
method: HttpMethod.post,
Expand All @@ -72,6 +73,7 @@ abstract class ApiClient {
validate: validate ?? environment.validateRequestsByDefaut,
isAuthorisedRequest:
isAuthorisedRequest ?? environment.isRequestsAuthorisedByDefault,
contentType: contentType,
));
}

Expand All @@ -83,6 +85,7 @@ abstract class ApiClient {
bool isAuthorisedRequest,
bool validate,
ResponseType responseType = ResponseType.json,
String contentType = Headers.jsonContentType,
}) {
return _request(RequestParams<T>(
method: HttpMethod.put,
Expand All @@ -94,6 +97,7 @@ abstract class ApiClient {
validate: validate ?? environment.validateRequestsByDefaut,
isAuthorisedRequest:
isAuthorisedRequest ?? environment.isRequestsAuthorisedByDefault,
contentType: contentType,
));
}

Expand Down Expand Up @@ -223,6 +227,7 @@ abstract class ApiClient {
var options = RequestOptions(
headers: _headers(params.headers),
responseType: params.responseType,
contentType: params.contentType,
);

if (params.isAuthorisedRequest) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/models/request_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RequestParams<T> {
this.responseType,
this.isAuthorisedRequest,
this.validate,
this.contentType,
});

final HttpMethod method;
Expand All @@ -25,4 +26,5 @@ class RequestParams<T> {
final ResponseType responseType;
final bool isAuthorisedRequest;
final bool validate;
final String contentType;
}
Loading