Skip to content

Commit 6df095b

Browse files
authored
Update README.md (#975)
Fixed what needs to be defined before the `savedDir` parameter. Fixed DownloadTaskStatus function. Fixed SendPort Optional. Fixed explicit loadTasks()'s type Co-authored-by: Neander <[email protected]>
1 parent 67b9a97 commit 6df095b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ void main() {
293293

294294
### Create new download task
295295

296+
The directory must be created in advance.
297+
After that, you need to provide the path of the directory in the `savedDir` parameter.
298+
296299
```dart
297300
final taskId = await FlutterDownloader.enqueue(
298301
url: 'your download link',
@@ -326,7 +329,7 @@ void initState() {
326329
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
327330
_port.listen((dynamic data) {
328331
String id = data[0];
329-
DownloadTaskStatus status = DownloadTaskStatus(data[1]);
332+
DownloadTaskStatus status = DownloadTaskStatus.fromInt(data[1]);
330333
int progress = data[2];
331334
setState((){ });
332335
});
@@ -342,8 +345,8 @@ void dispose() {
342345
343346
@pragma('vm:entry-point')
344347
static void downloadCallback(String id, int status, int progress) {
345-
final SendPort send = IsolateNameServer.lookupPortByName('downloader_send_port');
346-
send.send([id, status, progress]);
348+
final SendPort? send = IsolateNameServer.lookupPortByName('downloader_send_port');
349+
send?.send([id, status, progress]);
347350
}
348351
349352
```
@@ -354,13 +357,13 @@ avoid tree shaking in release mode for Android.
354357
### Load all download tasks
355358

356359
```dart
357-
final tasks = await FlutterDownloader.loadTasks();
360+
final List<DownloadTask>? tasks = await FlutterDownloader.loadTasks();
358361
```
359362

360363
### Load download tasks using a raw SQL query
361364

362365
```dart
363-
final tasks = await FlutterDownloader.loadTasksWithRawQuery(query: query);
366+
final List<DownloadTask>? tasks = await FlutterDownloader.loadTasksWithRawQuery(query: query);
364367
```
365368

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

0 commit comments

Comments
 (0)