Skip to content

Commit

Permalink
Improve usage example for Dio.download
Browse files Browse the repository at this point in the history
  • Loading branch information
hgraceb committed Aug 10, 2023
1 parent 0854519 commit 22e61b1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dio/lib/src/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ abstract class Dio {
/// ),
/// onReceiveProgress: (received, total) {
/// if (total != -1) {
/// print((received / total * 100).toStringAsFixed(0) + '%');
/// print('${(received / total * 100).toStringAsFixed(0)}%');
/// }
/// },
/// );
Expand Down
4 changes: 2 additions & 2 deletions example/lib/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Future download2(Dio dio, String url, String savePath) async {
}
}

void showDownloadProgress(received, total) {
void showDownloadProgress(int received, int total) {
if (total != -1) {
print((received / total * 100).toStringAsFixed(0) + '%');
print('${(received / total * 100).toStringAsFixed(0)}%');
}
}
8 changes: 0 additions & 8 deletions example/lib/formdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';

void showProgress(received, total) {
if (total != -1) {
print((received / total * 100).toStringAsFixed(0) + '%');
}
}

Future<FormData> formData1() async {
return FormData.fromMap({
'name': 'wendux',
Expand Down Expand Up @@ -92,7 +86,6 @@ void main() async {
final dio = Dio();
dio.options.baseUrl = 'http://localhost:3000/';
dio.interceptors.add(LogInterceptor());
// dio.interceptors.add(LogInterceptor(requestBody: true));
dio.httpClientAdapter = IOHttpClientAdapter(
createHttpClient: () {
final client = HttpClient();
Expand All @@ -116,7 +109,6 @@ void main() async {
print(utf8.decode(await data3.readAsBytes()));

response = await dio.post(
//"/upload",
'http://localhost:3000/upload',
data: data3,
onSendProgress: (received, total) {
Expand Down

0 comments on commit 22e61b1

Please sign in to comment.