-
-
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
Add support for download
function in web
#2230
base: main
Are you sure you want to change the base?
Conversation
download
function in web
This looks interesting, thanks! I read about We will need some tests and and likely an example. |
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.
Probably missing some error handling.
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.
Please write up a general idea of what behavior/standard it follows.
By further examining the web request, I realized that we use The problem of high memory is solved. thank you for checking again |
download
function in webdownload
function in web
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
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.
Still need some tests and examples here... 🛎️
Could you move on with the new structure of the code and add tests? |
# Conflicts: # dio/lib/src/adapters/browser_adapter.dart # dio/lib/src/dio/dio_for_browser.dart
changes are applied. thank you for checking again |
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.
Tests are still lacking.
dio/lib/src/options.dart
Outdated
/// Get blob url. | ||
/// Only work in web. |
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.
The description seems to lack explanation.
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 made changes to the description
if (options.responseType == ResponseType.blobUrl) { | ||
completer.complete( | ||
ResponseBody.fromString( | ||
Url.createObjectUrl(xhr.response), |
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.
Could you reuse other fields by constructing the ResponseBody
with the unnamed constructor?
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.
The ResponseBody
with the unnamed constructor requires steam, we have a url string !
changes are applied. thank you for checking again |
Please add tests. |
I tried to add the test, but I get the following error PS C:\Users\aaa\bbb\dio\plugins\web_adapter> flutter test
Error on line 10, column 3 of dart_test.yaml: Unknown platform "chrome".
╷
10 │ chrome:
│ ^^^^^^
╵ or PS C:\Users\aaa\bbb\dio\plugins\web_adapter\test> flutter test .\browser_test.dart
Changing current working directory to: C:\Users\aaa\bbb\dio\plugins\web_adapter
Error on line 10, column 3 of dart_test.yaml: Unknown platform "chrome".
╷
10 │ chrome:
│ ^^^^^^
╵ And I commented the contents of the "dart_test.yaml" file and run the tests again PS C:\Users\aaa\bbb\dio\plugins\web_adapter> flutter test
No tests ran.
No tests were found. or PS C:\Users\aaa\bbb\dio\plugins\web_adapter\test> flutter test .\browser_test.dart
Changing current working directory to: C:\Users\aaa\bbb\dio\plugins\web_adapter
No tests ran.
No tests were found. |
Try to set up the test like the GitHub workflow of this library. |
…orBrowser # Conflicts: # plugins/web_adapter/lib/src/adapter.dart # plugins/web_adapter/lib/src/dio_impl.dart
Test added |
RequestOptions( | ||
baseUrl: urlPath, | ||
data: data, | ||
method: 'GET', |
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.
Why always GET
?
final completer = Completer<Response>(); | ||
|
||
// Set response in Completer | ||
completer.complete(response); | ||
|
||
return completer.future; |
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.
These are unnecessary.
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.
What will the result be after downloaded? Could you demonstrate how it works?
EDIT: Please also add an example somewhere in our examples so everyone can run and see how it works.
New Pull Request Checklist
main
branch to avoid conflicts (via merge from master or rebase)CHANGELOG.md
in the corresponding packageAdditional context and info
In this PR, download support was added to dio with the help of
Blob
files.Note: There is no need to send
savePath
on the web and it can be empty.