Skip to content

Commit de0af65

Browse files
committed
update doc
1 parent 0bf69c8 commit de0af65

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

README-ZH.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,22 @@ dio.interceptors.add(InterceptorsWrapper(
342342
onRequest:(options, handler){
343343
// Do something before request is sent
344344
return handler.next(options); //continue
345-
// 如果你想完成请求并返回一些自定义数据,可以返回一个`Response`,如`dio.resolve(response)`。
345+
// 如果你想完成请求并返回一些自定义数据,你可以resolve一个Response对象 `handler.resolve(response)`。
346346
// 这样请求将会被终止,上层then会被调用,then中返回的数据将是你的自定义response.
347347
//
348-
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`dio.reject(error)`,
348+
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`handler.reject(error)`,
349349
// 这样请求将被中止并触发异常,上层catchError会被调用。
350350
},
351351
onResponse:(response,handler) {
352352
// Do something with response data
353353
return handler.next(response); // continue
354-
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`dio.reject(error)`,
354+
// 如果你想终止请求并触发一个错误,你可以 reject 一个`DioError`对象,如`handler.reject(error)`,
355355
// 这样请求将被中止并触发异常,上层catchError会被调用。
356356
},
357357
onError: (DioError e, handler) {
358358
// Do something with response error
359359
return handler.next(e);//continue
360-
// 如果你想完成请求并返回一些自定义数据,可以返回一个`Response`,如`dio.resolve(response)`。
360+
// 如果你想完成请求并返回一些自定义数据,可以resolve 一个`Response`,如`handler.resolve(response)`。
361361
// 这样请求将会被终止,上层then会被调用,then中返回的数据将是你的自定义response.
362362
}
363363
));
@@ -388,7 +388,7 @@ class CustomInterceptors extends Interceptor {
388388

389389
### 完成和终止请求/响应
390390

391-
在所有拦截器中,你都可以改变请求执行流, 如果你想完成请求/响应并返回自定义数据,你可以返回一个 `Response` 对象或返回 `dio.resolve(data)`的结果。 如果你想终止(触发一个错误,上层`catchError`会被调用)一个请求/响应,那么可以返回一个`DioError` 对象或返回 `dio.reject(errMsg)` 的结果.
391+
在所有拦截器中,你都可以改变请求执行流, 如果你想完成请求/响应并返回自定义数据,你可以resolve一个 `Response` 对象或返回 `handler.resolve(data)`的结果。 如果你想终止(触发一个错误,上层`catchError`会被调用)一个请求/响应,那么可以reject一个`DioError` 对象或返回 `handler.reject(errMsg)` 的结果.
392392

393393
```dart
394394
dio.interceptors.add(InterceptorsWrapper(

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -365,21 +365,21 @@ dio.interceptors.add(InterceptorsWrapper(
365365
// Do something before request is sent
366366
return handler.next(options); //continue
367367
// If you want to resolve the request with some custom data,
368-
// you can resolve a `Response` object eg: return `dio.resolve(response)`.
368+
// you can resolve a `Response` object eg: `handler.resolve(response)`.
369369
// If you want to reject the request with a error message,
370-
// you can reject a `DioError` object eg: return `dio.reject(dioError)`
370+
// you can reject a `DioError` object eg: `handler.reject(dioError)`
371371
},
372372
onResponse:(response,handler) {
373373
// Do something with response data
374374
return handler.next(response); // continue
375375
// If you want to reject the request with a error message,
376-
// you can reject a `DioError` object eg: return `dio.reject(dioError)`
376+
// you can reject a `DioError` object eg: `handler.reject(dioError)`
377377
},
378378
onError: (DioError e, handler) {
379379
// Do something with response error
380380
return handler.next(e);//continue
381381
// If you want to resolve the request with some custom data,
382-
// you can resolve a `Response` object eg: return `dio.resolve(response)`.
382+
// you can resolve a `Response` object eg: `handler.resolve(response)`.
383383
}
384384
));
385385
@@ -411,7 +411,7 @@ class CustomInterceptors extends Interceptor {
411411

412412
### Resolve and reject the request
413413

414-
In all interceptors, you can interfere with their execution flow. If you want to resolve the request/response with some custom data,you can return a `Response` object or return `dio.resolve(data)`. If you want to reject the request/response with a error message, you can return a `DioError` object or return `dio.reject(errMsg)` .
414+
In all interceptors, you can interfere with their execution flow. If you want to resolve the request/response with some custom data,you can call `handler.resolve(Response)`. If you want to reject the request/response with a error message, you can call `handler.reject(dioError)` .
415415

416416
```dart
417417
dio.interceptors.add(InterceptorsWrapper(

dio/README-ZH.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,22 @@ dio.interceptors.add(InterceptorsWrapper(
342342
onRequest:(options, handler){
343343
// Do something before request is sent
344344
return handler.next(options); //continue
345-
// 如果你想完成请求并返回一些自定义数据,可以返回一个`Response`,如`dio.resolve(response)`。
345+
// 如果你想完成请求并返回一些自定义数据,你可以resolve一个Response对象 `handler.resolve(response)`。
346346
// 这样请求将会被终止,上层then会被调用,then中返回的数据将是你的自定义response.
347347
//
348-
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`dio.reject(error)`,
348+
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`handler.reject(error)`,
349349
// 这样请求将被中止并触发异常,上层catchError会被调用。
350350
},
351351
onResponse:(response,handler) {
352352
// Do something with response data
353353
return handler.next(response); // continue
354-
// 如果你想终止请求并触发一个错误,你可以返回一个`DioError`对象,如`dio.reject(error)`,
354+
// 如果你想终止请求并触发一个错误,你可以 reject 一个`DioError`对象,如`handler.reject(error)`,
355355
// 这样请求将被中止并触发异常,上层catchError会被调用。
356356
},
357357
onError: (DioError e, handler) {
358358
// Do something with response error
359359
return handler.next(e);//continue
360-
// 如果你想完成请求并返回一些自定义数据,可以返回一个`Response`,如`dio.resolve(response)`。
360+
// 如果你想完成请求并返回一些自定义数据,可以resolve 一个`Response`,如`handler.resolve(response)`。
361361
// 这样请求将会被终止,上层then会被调用,then中返回的数据将是你的自定义response.
362362
}
363363
));
@@ -388,7 +388,7 @@ class CustomInterceptors extends Interceptor {
388388

389389
### 完成和终止请求/响应
390390

391-
在所有拦截器中,你都可以改变请求执行流, 如果你想完成请求/响应并返回自定义数据,你可以返回一个 `Response` 对象或返回 `dio.resolve(data)`的结果。 如果你想终止(触发一个错误,上层`catchError`会被调用)一个请求/响应,那么可以返回一个`DioError` 对象或返回 `dio.reject(errMsg)` 的结果.
391+
在所有拦截器中,你都可以改变请求执行流, 如果你想完成请求/响应并返回自定义数据,你可以resolve一个 `Response` 对象或返回 `handler.resolve(data)`的结果。 如果你想终止(触发一个错误,上层`catchError`会被调用)一个请求/响应,那么可以reject一个`DioError` 对象或返回 `handler.reject(errMsg)` 的结果.
392392

393393
```dart
394394
dio.interceptors.add(InterceptorsWrapper(

dio/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -365,21 +365,21 @@ dio.interceptors.add(InterceptorsWrapper(
365365
// Do something before request is sent
366366
return handler.next(options); //continue
367367
// If you want to resolve the request with some custom data,
368-
// you can resolve a `Response` object eg: return `dio.resolve(response)`.
368+
// you can resolve a `Response` object eg: `handler.resolve(response)`.
369369
// If you want to reject the request with a error message,
370-
// you can reject a `DioError` object eg: return `dio.reject(dioError)`
370+
// you can reject a `DioError` object eg: `handler.reject(dioError)`
371371
},
372372
onResponse:(response,handler) {
373373
// Do something with response data
374374
return handler.next(response); // continue
375375
// If you want to reject the request with a error message,
376-
// you can reject a `DioError` object eg: return `dio.reject(dioError)`
376+
// you can reject a `DioError` object eg: `handler.reject(dioError)`
377377
},
378378
onError: (DioError e, handler) {
379379
// Do something with response error
380380
return handler.next(e);//continue
381381
// If you want to resolve the request with some custom data,
382-
// you can resolve a `Response` object eg: return `dio.resolve(response)`.
382+
// you can resolve a `Response` object eg: `handler.resolve(response)`.
383383
}
384384
));
385385
@@ -411,7 +411,7 @@ class CustomInterceptors extends Interceptor {
411411

412412
### Resolve and reject the request
413413

414-
In all interceptors, you can interfere with their execution flow. If you want to resolve the request/response with some custom data,you can return a `Response` object or return `dio.resolve(data)`. If you want to reject the request/response with a error message, you can return a `DioError` object or return `dio.reject(errMsg)` .
414+
In all interceptors, you can interfere with their execution flow. If you want to resolve the request/response with some custom data,you can call `handler.resolve(Response)`. If you want to reject the request/response with a error message, you can call `handler.reject(dioError)` .
415415

416416
```dart
417417
dio.interceptors.add(InterceptorsWrapper(

dio/lib/src/transformer.dart

+12-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ abstract class Transformer {
3838
Map map, [
3939
ListFormat listFormat = ListFormat.multi,
4040
]) {
41-
return encodeMap(map, (key, value) {
42-
if (value == null) return key;
43-
return '$key=${Uri.encodeQueryComponent(value.toString())}';
44-
}, listFormat: listFormat);
41+
return encodeMap(
42+
map,
43+
(key, value) {
44+
if (value == null) return key;
45+
return '$key=${Uri.encodeQueryComponent(value.toString())}';
46+
},
47+
listFormat: listFormat,
48+
);
4549
}
4650
}
4751

@@ -146,7 +150,10 @@ class DefaultTransformer extends Transformer {
146150
String? responseBody;
147151
if (options.responseDecoder != null) {
148152
responseBody = options.responseDecoder!(
149-
responseBytes, options, response..stream = Stream.empty());
153+
responseBytes,
154+
options,
155+
response..stream = Stream.empty(),
156+
);
150157
} else {
151158
responseBody = utf8.decode(responseBytes, allowMalformed: true);
152159
}

0 commit comments

Comments
 (0)