Skip to content
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

Made a few edits to the Android-related explanations in the README.md #975

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ void main() {

### Create new download task

The directory must be created in advance.
After that, you need to provide the path of the directory in the `savedDir` parameter.

```dart
final taskId = await FlutterDownloader.enqueue(
url: 'your download link',
Expand Down Expand Up @@ -326,7 +329,7 @@ void initState() {
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = DownloadTaskStatus(data[1]);
DownloadTaskStatus status = DownloadTaskStatus.fromInt(data[1]);
int progress = data[2];
setState((){ });
});
Expand All @@ -342,8 +345,8 @@ void dispose() {

@pragma('vm:entry-point')
static void downloadCallback(String id, int status, int progress) {
final SendPort send = IsolateNameServer.lookupPortByName('downloader_send_port');
send.send([id, status, progress]);
final SendPort? send = IsolateNameServer.lookupPortByName('downloader_send_port');
send?.send([id, status, progress]);
}

```
Expand All @@ -354,13 +357,13 @@ avoid tree shaking in release mode for Android.
### Load all download tasks

```dart
final tasks = await FlutterDownloader.loadTasks();
final List<DownloadTask>? tasks = await FlutterDownloader.loadTasks();
```

### Load download tasks using a raw SQL query

```dart
final tasks = await FlutterDownloader.loadTasksWithRawQuery(query: query);
final List<DownloadTask>? tasks = await FlutterDownloader.loadTasksWithRawQuery(query: query);
```

In order to parse data into `DownloadTask` object successfully, you should load
Expand Down