question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

While the <kbd>flutter_downloader</kbd> 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 DownloadTasks 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:

final task = await DownloadTask.create(
  url: 'https://...',
  downloadDirectory: getApplicationDirectory(),
);
task.updates.forEach(print);
task.onCompleted(() => task.openFile());

await Future.delayed(Duration(seconds: 3));
if (!task.isCompleted) {
  print('Download takes longer than three seconds.');
}

await task.waitUntilCompleted();

By using Streams 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:

// inside a widget's State

DownloadTask task;

void _startDownload() {
  setState(() => task = DownloadTask.create(…));
}

Widget build(BuildContext context) {
  return Column(
    children: <Widget>[
      RaisedButton(onPressed: _startDownload, child: Text('Start download')),
      StreamBuilder<void>(
        stream: task?.updates ?? Stream.empty(),
        builder: (context, _) => Text('Progress: ${task?.progress}'),
      ),
    ],
  );
}

What do you think about this API?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
qq326646683commented, Sep 3, 2020

same issue on Android, these works for me:

provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <root-path
        name="root"
        path="." />
</paths>
1reaction
sqrgcommented, Sep 1, 2020

Sure, I can take a look on macOS. I don’t have much experience nor knowledge, but I’ll take a look

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cleanup API - Vertuna WIKI - ConfiForms
You can use it to cleanup data stored by ConfiForms plugin, all data or filtered by filter criteria. Same format as for filters...
Read more >
How to Use Your Data Cleaning APIs - Classr
Your Data Cleaning API, as well as your Taxonomy API and Entity API, is automatically created when you initially create a taxonomy. The...
Read more >
How to write a clean API. Best Practices for REST ... - ITNEXT
Key Requirements for a clean API · Be simple (Flat is better than nested.) · Be consistent (Standardize the style before you start)...
Read more >
Clean API Architecture | Perry Street Software Engineering
In another blog series we describe how we applied Clean to our mobile applications. Today, we are going to talk about how we...
Read more >
Business Event System Cleanup API (Oracle Workflow API ...
The Workflow Business Event System cleanup API can be used to clean up the standard WF_CONTROL queue in the Business Event System by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found