// ignore: annotate_overrides import 'dart:async'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:shared_preferences/shared_preferences.dart'; @pragma('vm:entry-point') Future onServisStart(ServiceInstance service) async { final prefs = await SharedPreferences.getInstance(); bool stopService = false; prefs.reload(); // The magic line // ignore: unused_local_variable // final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = // FlutterLocalNotificationsPlugin(); // final Timer timer; service.on("mesaici.servis.durdur").listen((event) async { // print(event); stopService = true; service.stopSelf(); service.invoke("mesaici.servis.olay.durduruldu"); }); service.invoke("mesaici.servis.olay.baslatildi"); // bring to foreground Timer.periodic(const Duration(seconds: 1), (timer) async { if (stopService) { service.stopSelf(); timer.cancel(); service.invoke("mesaici.servis.olay.durduruldu"); } service.invoke("mesaici.servis.olay.calisiyor"); // flutterLocalNotificationsPlugin.show( // 1, // 'FikoYT - Çalışmanız Devam Ediyor', // 'Çalışma Süresi ${DateTime.now()}', // const NotificationDetails( // android: AndroidNotificationDetails( // "Genel", // 'FikoYT Servis', // icon: 'ic_bg_service_small', // ongoing: false, // enableVibration: false, // channelShowBadge: true, // silent: true, // ), // ), // ); // }); }