@@ -55,10 +55,10 @@ class FlutterDownloaderPlugin : MethodChannel.MethodCallHandler, FlutterPlugin {
5555 " initialize" -> initialize(call, result)
5656 " registerCallback" -> registerCallback(call, result)
5757 " enqueue" -> enqueue(call, result)
58- " loadTasks" -> loadTasks(call, result)
58+ " loadTasks" -> loadTasks(result)
5959 " loadTasksWithRawQuery" -> loadTasksWithRawQuery(call, result)
6060 " cancel" -> cancel(call, result)
61- " cancelAll" -> cancelAll(call, result)
61+ " cancelAll" -> cancelAll(result)
6262 " pause" -> pause(call, result)
6363 " resume" -> resume(call, result)
6464 " retry" -> retry(call, result)
@@ -170,20 +170,38 @@ class FlutterDownloaderPlugin : MethodChannel.MethodCallHandler, FlutterPlugin {
170170 val saveInPublicStorage: Boolean = call.requireArgument(" save_in_public_storage" )
171171 val allowCellular: Boolean = call.requireArgument(" allow_cellular" )
172172 val request: WorkRequest = buildRequest(
173- url, savedDir, filename, headers, showNotification,
174- openFileFromNotification, false , requiresStorageNotLow, saveInPublicStorage, timeout, allowCellular = allowCellular
173+ url,
174+ savedDir,
175+ filename,
176+ headers,
177+ showNotification,
178+ openFileFromNotification,
179+ false ,
180+ requiresStorageNotLow,
181+ saveInPublicStorage,
182+ timeout,
183+ allowCellular = allowCellular
175184 )
176185 WorkManager .getInstance(requireContext()).enqueue(request)
177186 val taskId: String = request.id.toString()
178187 result.success(taskId)
179188 sendUpdateProgress(taskId, DownloadStatus .ENQUEUED , 0 )
180189 taskDao!! .insertOrUpdateNewTask(
181- taskId, url, DownloadStatus .ENQUEUED , 0 , filename,
182- savedDir, headers, showNotification, openFileFromNotification, saveInPublicStorage, allowCellular = allowCellular
190+ taskId,
191+ url,
192+ DownloadStatus .ENQUEUED ,
193+ 0 ,
194+ filename,
195+ savedDir,
196+ headers,
197+ showNotification,
198+ openFileFromNotification,
199+ saveInPublicStorage,
200+ allowCellular = allowCellular
183201 )
184202 }
185203
186- private fun loadTasks (call : MethodCall , result : MethodChannel .Result ) {
204+ private fun loadTasks (result : MethodChannel .Result ) {
187205 val tasks = taskDao!! .loadAllTasks()
188206 val array: MutableList <Map <* , * >> = ArrayList ()
189207 for (task in tasks) {
@@ -226,7 +244,7 @@ class FlutterDownloaderPlugin : MethodChannel.MethodCallHandler, FlutterPlugin {
226244 result.success(null )
227245 }
228246
229- private fun cancelAll (call : MethodCall , result : MethodChannel .Result ) {
247+ private fun cancelAll (result : MethodChannel .Result ) {
230248 WorkManager .getInstance(requireContext()).cancelAllWorkByTag(TAG )
231249 result.success(null )
232250 }
@@ -256,9 +274,17 @@ class FlutterDownloaderPlugin : MethodChannel.MethodCallHandler, FlutterPlugin {
256274 val partialFile = File (partialFilePath)
257275 if (partialFile.exists()) {
258276 val request: WorkRequest = buildRequest(
259- task.url, task.savedDir, task.filename,
260- task.headers, task.showNotification, task.openFileFromNotification,
261- true , requiresStorageNotLow, task.saveInPublicStorage, timeout, allowCellular = task.allowCellular
277+ task.url,
278+ task.savedDir,
279+ task.filename,
280+ task.headers,
281+ task.showNotification,
282+ task.openFileFromNotification,
283+ true ,
284+ requiresStorageNotLow,
285+ task.saveInPublicStorage,
286+ timeout,
287+ allowCellular = task.allowCellular
262288 )
263289 val newTaskId: String = request.id.toString()
264290 result.success(newTaskId)
0 commit comments