From 35ea5ed67695b80cfafd6509aca91e6d5e567636 Mon Sep 17 00:00:00 2001 From: lone-wolf Date: Sun, 20 Jun 2021 02:12:39 +0100 Subject: [PATCH] ** Improved the function type specification of BackgroundFetch.registerHeadlessTask from "BackgroundFetch.registerHeadlessTask(Function callback)" to "BackgroundFetch.registerHeadlessTask(Function(HeadlessTask) callback)" ** also improved the BackgroundFetch.configure parameter "onFetch" Function declaration from "Function onFetch" to "Function(String taskId) onFetch". A similar thing was done for the "onTimeout" parameter --- lib/background_fetch.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/background_fetch.dart b/lib/background_fetch.dart index e8cde38..962a317 100644 --- a/lib/background_fetch.dart +++ b/lib/background_fetch.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:ui'; -import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; const _PLUGIN_PATH = "com.transistorsoft/flutter_background_fetch"; const _METHOD_CHANNEL_NAME = "$_PLUGIN_PATH/methods"; @@ -418,8 +418,9 @@ class BackgroundFetch { /// BackgroundFetch.finish(taskId); /// }) /// ``` - static Future configure(BackgroundFetchConfig config, Function onFetch, - [Function? onTimeout]) { + static Future configure( + BackgroundFetchConfig config, Function(String taskId) onFetch, + [Function(String taskId)? onTimeout]) { if (_eventsFetch == null) { _eventsFetch = _eventChannelTask.receiveBroadcastStream(); if (onTimeout == null) { @@ -605,7 +606,8 @@ class BackgroundFetch { /// } /// ``` /// - static Future registerHeadlessTask(Function callback) async { + static Future registerHeadlessTask( + Function(HeadlessTask task) callback) async { Completer completer = Completer(); // Two callbacks: the provided headless-task + _headlessRegistrationCallback