Skip to content

Commit

Permalink
Fixed the request replace due to Dart2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Jul 2, 2018
1 parent ece775e commit e9917fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions simple_auth/lib/src/converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BodyConverterCodec extends Converter {
if (request.body == null) {
return request;
}
return request.replace(body: codec.encode(request.body));
return request.replaceBody(codec.encode(request.body));
}

Future<Response> decode(Response response, Type responseType) async {
Expand All @@ -46,6 +46,6 @@ class JsonConverter extends BodyConverterCodec {
if (request.body is JsonSerializable) {
body = (request.body as JsonSerializable).toJson();
}
return super.encode(request.replace(body: body));
return super.encode(request.replaceBody(body));
}
}
11 changes: 10 additions & 1 deletion simple_auth/lib/src/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ class Request {
Request replace(
{HttpMethod method,
String url,
Map<String, dynamic> parameters,
Map<String, String> headers,
Encoding encoding}) =>
new Request(method ?? this.method, url ?? this.url,
parameters: parameters ?? this.parameters,
headers: headers ?? this.headers, authenticated: this.authenticated);
Request replaceBody(
dynamic body,
{HttpMethod method,
String url,
Map<String, dynamic> parameters,
Map<String, String> headers,
Encoding encoding}) =>
new Request(method ?? this.method, url ?? this.url,
body: body ?? this.body,
body: body,
parameters: parameters ?? this.parameters,
headers: headers ?? this.headers, authenticated: this.authenticated);

Expand Down

0 comments on commit e9917fc

Please sign in to comment.