-
Notifications
You must be signed in to change notification settings - Fork 522
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
Clean up api #256
Comments
Sounds great. Let me know if you need supports in native sides |
When invoking the native method
Any idea why that occurs? |
I temporarily fixed this error with the help of @JonasWanke. The issue was that on Android, the package only supports saving to external directories, not to app directories. That's probably because the resolution of the Regarding some architectural decisions that I stumbled upon: Why was Java used instead of Kotlin? Why is there an SQL database in the background instead of just communicating with the Dart side? |
I prefer Java to Kotlin because I don't have much experiences in Kotlin.
If there's no SQL database, where do you store download task data? If you ask me that why the plugin need to maintain the download task data, my answer is that it's designed in that way, a library for downloading management that users can fire and forget instead of just creating a download task and leaving users with all stuff of download state management. |
BTW, your issue related to Android Storage problem, it's not true that the plugin only supports saving to external directories. You can save your files in internal storage if you set the value of |
Ohhh I see. I'm not experienced with native Android and didn't know that limitation exists, but it makes sense. We should probably document that behavior in the API as well. |
In the related issue in our app (hpi-schul-cloud/schulcloud-flutter#61), @JonasWanke mentioned that it's possible to store downloaded files in your app's private directory and grant other apps temporary read access to it: https://developer.android.com/training/secure-file-sharing/share-file#GrantPermissions |
The plugin has already implemented that flow. Have a look at: https://github.com/fluttercommunity/flutter_downloader/blob/master/android/src/main/java/vn/hunghd/flutterdownloader/IntentUtils.java#L29 |
@MarcelGarus Will this also take care of moving the callback from the background isolate of the native plugin to the main isolate in the UI so that we don't have to manage this ourselves? |
Of course! In Dart, most of the time, asynchronous operations are the way to go. So, on any var task = ...;
await Future.delayed(Duration(seconds: 1));
print(task.status); |
Any updates on this? Is there any workaround to wait for a file to finish downloading? |
There are some minor issues left in the PR #283. In the meantime, you could register a callback for download progress, create a |
Sure, I can take a look on macOS. I don't have much experience nor knowledge, but I'll take a look |
same issue on Android, these works for me:
|
I'm new to flutter, so I apologize if my question is stupid, but how do I use the Thanks! |
It's a pity that this PR died, would be great if the API had better design. |
While the flutter_downloader works fine, its API doesn't conform to idiomatic Dart standards in some cases.
That's why I'm currently rewriting the Dart side of the plugin to make it more intuitive.
If implemented, this will be a breaking change and thus require a new major version update.
Especially the
DownloadTask
s are currently merely a wrapper around some data and not really actionable. I'm looking forward to rewriting the API so that something like the following is possible:By using
Stream
s rather than callbacks, it's possible to leverage Dart's strengths of async/await, applying stream transformations and support from the ecosystem. For example, one could easily build a Flutter widget like the following:What do you think about this API?
The text was updated successfully, but these errors were encountered: