@@ -16,7 +16,8 @@ import 'models.dart';
16
16
/// * `progress` : current progress value of a download task, the value is in
17
17
/// range of 0 and 100
18
18
///
19
- typedef void DownloadCallback (String id, DownloadTaskStatus status, int progress);
19
+ typedef void DownloadCallback (
20
+ String id, DownloadTaskStatus status, int progress);
20
21
21
22
///
22
23
/// A convenient class wraps all api functions of **FlutterDownloader** plugin
@@ -26,7 +27,8 @@ class FlutterDownloader {
26
27
static bool _initialized = false ;
27
28
28
29
static Future <Null > initialize () async {
29
- assert (! _initialized, 'FlutterDownloader.initialize() must be called only once!' );
30
+ assert (! _initialized,
31
+ 'FlutterDownloader.initialize() must be called only once!' );
30
32
31
33
WidgetsFlutterBinding .ensureInitialized ();
32
34
@@ -62,12 +64,12 @@ class FlutterDownloader {
62
64
///
63
65
static Future <String > enqueue (
64
66
{@required String url,
65
- @required String savedDir,
66
- String fileName,
67
- Map <String , String > headers,
68
- bool showNotification = true ,
69
- bool openFileFromNotification = true ,
70
- bool requiresStorageNotLow = true }) async {
67
+ @required String savedDir,
68
+ String fileName,
69
+ Map <String , String > headers,
70
+ bool showNotification = true ,
71
+ bool openFileFromNotification = true ,
72
+ bool requiresStorageNotLow = true }) async {
71
73
assert (_initialized, 'FlutterDownloader.initialize() must be called first' );
72
74
assert (Directory (savedDir).existsSync ());
73
75
@@ -112,12 +114,12 @@ class FlutterDownloader {
112
114
List <dynamic > result = await _channel.invokeMethod ('loadTasks' );
113
115
return result
114
116
.map ((item) => new DownloadTask (
115
- taskId: item['task_id' ],
116
- status: DownloadTaskStatus (item['status' ]),
117
- progress: item['progress' ],
118
- url: item['url' ],
119
- filename: item['file_name' ],
120
- savedDir: item['saved_dir' ]))
117
+ taskId: item['task_id' ],
118
+ status: DownloadTaskStatus (item['status' ]),
119
+ progress: item['progress' ],
120
+ url: item['url' ],
121
+ filename: item['file_name' ],
122
+ savedDir: item['saved_dir' ]))
121
123
.toList ();
122
124
} on PlatformException catch (e) {
123
125
print (e.message);
@@ -155,12 +157,12 @@ class FlutterDownloader {
155
157
print ('Loaded tasks: $result ' );
156
158
return result
157
159
.map ((item) => new DownloadTask (
158
- taskId: item['task_id' ],
159
- status: DownloadTaskStatus (item['status' ]),
160
- progress: item['progress' ],
161
- url: item['url' ],
162
- filename: item['file_name' ],
163
- savedDir: item['saved_dir' ]))
160
+ taskId: item['task_id' ],
161
+ status: DownloadTaskStatus (item['status' ]),
162
+ progress: item['progress' ],
163
+ url: item['url' ],
164
+ filename: item['file_name' ],
165
+ savedDir: item['saved_dir' ]))
164
166
.toList ();
165
167
} on PlatformException catch (e) {
166
168
print (e.message);
@@ -385,8 +387,9 @@ class FlutterDownloader {
385
387
assert (_initialized, 'FlutterDownloader.initialize() must be called first' );
386
388
387
389
final callbackHandle = PluginUtilities .getCallbackHandle (callback);
388
- assert (callbackHandle != null , 'callback must be a top-level or a static function' );
389
- _channel.invokeMethod ('registerCallback' , < dynamic > [callbackHandle.toRawHandle ()]);
390
+ assert (callbackHandle != null ,
391
+ 'callback must be a top-level or a static function' );
392
+ _channel.invokeMethod (
393
+ 'registerCallback' , < dynamic > [callbackHandle.toRawHandle ()]);
390
394
}
391
-
392
395
}
0 commit comments