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

Function Type Specification for Headless Tasks, onFetch and onTimeout #228

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
10 changes: 6 additions & 4 deletions lib/background_fetch.dart
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -418,8 +418,9 @@ class BackgroundFetch {
/// BackgroundFetch.finish(taskId);
/// })
/// ```
static Future<int> configure(BackgroundFetchConfig config, Function onFetch,
[Function? onTimeout]) {
static Future<int> configure(
BackgroundFetchConfig config, Function(String taskId) onFetch,
[Function(String taskId)? onTimeout]) {
if (_eventsFetch == null) {
_eventsFetch = _eventChannelTask.receiveBroadcastStream();
if (onTimeout == null) {
Expand Down Expand Up @@ -605,7 +606,8 @@ class BackgroundFetch {
/// }
/// ```
///
static Future<bool> registerHeadlessTask(Function callback) async {
static Future<bool> registerHeadlessTask(
Function(HeadlessTask task) callback) async {
Completer completer = Completer<bool>();

// Two callbacks: the provided headless-task + _headlessRegistrationCallback
Expand Down