-
Notifications
You must be signed in to change notification settings - Fork 518
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 #283
Clean up API #283
Conversation
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.
Great, it's more functional programming now.
final progress = data[2] as double; | ||
_tasksById[id]?._update(status, progress); | ||
}); | ||
IsolateNameServer.registerPortWithName(port.sendPort, 'downloader_port'); |
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.
Do you think that we need a way to removePortNameMapping ()
somewhere?
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 don't think so. FlutterDownloader
only offers static methods, so there are no multiple intances of FlutterDownloader
running at any time. Thus, there's never a naming conflict between ports.
Theoretically, we could add a dispose
method, but when the app/DartVM is stopped, it automatically cleans up these resources for us, so I don't think there's a need for it.
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.
Ok, I think it makes sense
I still got a few extra thoughts:
|
I just tried your new design for the example project in Android. There's a problem that causes user lost the status of current tasks in UI if they quit the application by using back button. |
Sorry for the late reply, I had some other stuff to do. I implemented the restoring of tasks on app restarts – it would be great if you could have another look at it! |
|
Your new design example project makes me quite confused:
|
I changed the example so it looks more like the previous one. Have a look: I also changed the loadTasksWithRawQueryConcerning The fact that // Load failed tasks from the last week.
final tasks = FlutterDownloader.loadTasks(
status: DownloadTaskStatus.failed,
createdAfter: DateTime.now() - Duration(days: 7),
); That would give us the opportunity to implement the feature once and everyone would benefit:
Of course, this isn't as powerful as providing a raw SQL interface, but gives developers less opportunity to mess something up – all queries will be guaranteed to be safe. We can then implement higher-level methods (or additional filter parameters for That being said, I'm not even sure this change would affect that many people – like you said, Usage of
|
@hnvn Any updates? |
Sorry for late response, I am quite busy this time. I will try to work on this PR next week. |
I'm working on your source codes but I cannot get packages with this error:
My Flutter version:
|
cc @JonasWanke |
I can publish a new version of black_hole_flutter with support for dartx v0.4.x. It seems that their v0.4.1 release now supports both Flutter stable and beta. |
Any update @MarcelGarus , I still cannot run the example project on beta channel |
Yup, still waiting for @JonasWanke to push an update of black_hole_flutter, which is used in the example |
Sorry for the delay, I hope I'll get the update out tomorrow. Note that you can specify |
True. Did that, (still) works fine on my device |
Finally had the time to push the update: v0.2.12 |
Any update @MarcelGarus ? |
Oh sure, here we go. |
I agree with two points you mention above but your example project still has issues:
|
Glad that you agree. |
Okay, so I debugged and restructured the code in the example to be even more readable. Now, on Android, if you close the app and restart it, already downloaded tasks are recognized and are displayed as downloaded – the example gets the tasks from the native side and then binds them to the existing files. However, it seems like the native side restarts the download every time the app is opened. I can try to look into that, but I'm not really experienced with native Android development, so it would be really great if someone could help out there. Regarding iOS, I have no idea how that could be – the changes shouldn't affect the opening of files in any way. I have no iPhone or MacBook, so I can't reproduce and fix the bug. |
This was a great discussion. An awesome upgrade is happening in #793, so I'm closing this. |
This PR changes none of the functionality of this package, only the API itself.
Now, there exist
DownloadTask
s that encapsulate all actions related to a specific download.DownloadTask
s are also automatically kept up-to-date by the package.Check out the example to see how the new API looks like when it's used.
Todo: