import 'dart:io'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:freezer/api/download_manager/download_service.dart'; import 'package:freezer/translations.i18n.dart'; class DownloadManager { Future startService() { if (Platform.isAndroid) { return FlutterBackgroundService().configure( iosConfiguration: IosConfiguration(), // fuck ios androidConfiguration: AndroidConfiguration( onStart: _startService, isForegroundMode: false, autoStart: false, autoStartOnBoot: false, foregroundServiceNotificationId: DownloadService.NOTIFICATION_ID, notificationChannelId: DownloadService.NOTIFICATION_CHANNEL_ID, initialNotificationTitle: 'Freezer'.i18n, initialNotificationContent: 'Starting download service...'.i18n, )); } _startService(null); return Future.value(true); } static void _startService(ServiceInstance? service) => DownloadService(service).run(); }