Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
duwen committed Feb 25, 2019
1 parent 8246139 commit 733cb80
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
12 changes: 9 additions & 3 deletions example/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ main() async {
dio.options.baseUrl = "http://www.dtworkroom.com/doris/1/2.0.0/";
dio.options.connectTimeout = 5000; //5s
dio.options.receiveTimeout = 5000;
dio.options.headers = {'user-agent': 'dio', 'common-header': 'xx'};
dio.options.headers = {
HttpHeaders.userAgentHeader: 'dio',
'common-header': 'xx',
};

// Or you can create dio instance and config it as follow:
// var dio = Dio(BaseOptions(
// var dio = Dio(BaseOptions(
// baseUrl: "http://www.dtworkroom.com/doris/1/2.0.0/",
// connectTimeout: 5000,
// receiveTimeout: 5000,
// headers: {'user-agent': 'dio', 'common-header': 'xx'},
// headers: {
// HttpHeaders.userAgentHeader: 'dio',
// 'common-header': 'xx',
// },
// ));

dio.interceptors
Expand Down
5 changes: 4 additions & 1 deletion example/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ main() async {
connectTimeout: 5000,
receiveTimeout: 100000,
// 5s
headers: {"user-agent": "dio", "api": "1.0.0"},
headers: {
HttpHeaders.userAgentHeader: "dio",
"api": "1.0.0",
},
contentType: ContentType.json,
// Transform the response data to a String encoded with UTF8.
// The default value is [ResponseType.JSON].
Expand Down
4 changes: 2 additions & 2 deletions package_src/lib/src/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef ProgressCallback = void Function(int count, int total);
/// dio.options.baseUrl = "http://www.dtworkroom.com/doris/1/2.0.0/";
/// dio.options.connectTimeout = 5000; //5s
/// dio.options.receiveTimeout = 5000;
/// dio.options.headers = {'user-agent': 'dio', 'common-header': 'xx'};
/// dio.options.headers = {HttpHeaders.userAgentHeader: 'dio', 'common-header': 'xx'};
/// ```
/// 2. create and config it:
///
Expand All @@ -44,7 +44,7 @@ typedef ProgressCallback = void Function(int count, int total);
/// baseUrl: "http://www.dtworkroom.com/doris/1/2.0.0/",
/// connectTimeout: 5000,
/// receiveTimeout: 5000,
/// headers: {'user-agent': 'dio', 'common-header': 'xx'},
/// headers: {HttpHeaders.userAgentHeader: 'dio', 'common-header': 'xx'},
/// ));
/// ```
Expand Down

0 comments on commit 733cb80

Please sign in to comment.