-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve usage example and tests #1933
Conversation
dio/lib/src/dio.dart
Outdated
/// onReceiveProgress: (received, total) { | ||
/// if (total != -1) { | ||
/// print((received / total * 100).toStringAsFixed(0) + '%'); | ||
/// print('${(received / total * 100).toStringAsFixed(0)}%'); | ||
/// } | ||
/// }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// onReceiveProgress: (received, total) { | |
/// if (total != -1) { | |
/// print((received / total * 100).toStringAsFixed(0) + '%'); | |
/// print('${(received / total * 100).toStringAsFixed(0)}%'); | |
/// } | |
/// }, | |
/// onReceiveProgress: (received, total) { | |
/// if(total < 1) return; | |
/// final percentage = (received / total * 100).toStringAsFixed(0) | |
/// print('$percentage%'); | |
/// }, |
example/lib/download.dart
Outdated
if (total != -1) { | ||
print((received / total * 100).toStringAsFixed(0) + '%'); | ||
print('${(received / total * 100).toStringAsFixed(0)}%'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (total != -1) { | |
print((received / total * 100).toStringAsFixed(0) + '%'); | |
print('${(received / total * 100).toStringAsFixed(0)}%'); | |
} | |
if (total < 1) return; | |
final percentage = (received / total * 100).toStringAsFixed(0) | |
print('$percentage%'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I replaced
1
with0
because0
is the actual boundary value. - I merged the definition and the
print
statement together.
- if (total < 1) return;
- final percentage = (received / total * 100).toStringAsFixed(0)
- print('$percentage%');
+ if (total <= 0) return;
+ print('percentage: ${(received / total * 100).toStringAsFixed(0)}%');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced 1 with 0 because 0 is the actual boundary value.
That's fine for me.
I merged the definition and the print statement together.
I believe that's harder to read, but since no one else complained, it seems like that's a me problem :D
}, | ||
); | ||
} | ||
|
||
/// Downloading by spiting as file in chunks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Dio.download
.example/lib/download_with_trunks
.total
argument ofonReceiveProgress
is not-1
inexample/lib/download
.New Pull Request Checklist
main
branch to avoid conflicts (via merge from master or rebase)CHANGELOG.md
in the corresponding packageAdditional context and info (if any)
There was no warning previously due to the default
dynamic
parameter type.