You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
581 B
Dart
23 lines
581 B
Dart
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
|
|
|
void startCallback() {
|
|
FlutterForegroundTask.setTaskHandler(MyTaskHandler());
|
|
}
|
|
|
|
class MyTaskHandler extends TaskHandler {
|
|
@override
|
|
Future<void> onStart(DateTime timestamp, TaskStarter? starter) async {
|
|
// Initialization code, e.g. open DB or services
|
|
}
|
|
|
|
@override
|
|
Future<void> onDestroy(DateTime timestamp, bool isTimeout) async {
|
|
// Clean up if needed
|
|
}
|
|
|
|
@override
|
|
void onRepeatEvent(DateTime timestamp) {
|
|
// Called based on the eventAction set in ForegroundTaskOptions
|
|
}
|
|
}
|