|
|
|
|
@ -13,53 +13,6 @@ void main() async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
await AppDependencies.addDependencies();
|
|
|
|
|
await WakelockPlus.enable();
|
|
|
|
|
|
|
|
|
|
// The following foreground task logic is now handled natively in Android. Commented out for clarity.
|
|
|
|
|
/*
|
|
|
|
|
void _initializeForegroundTask() {
|
|
|
|
|
FlutterForegroundTask.init(
|
|
|
|
|
androidNotificationOptions: AndroidNotificationOptions(
|
|
|
|
|
channelId: 'foreground_service',
|
|
|
|
|
channelName: AppStrings.appName,
|
|
|
|
|
channelDescription: '',
|
|
|
|
|
onlyAlertOnce: true,
|
|
|
|
|
),
|
|
|
|
|
iosNotificationOptions: const IOSNotificationOptions(
|
|
|
|
|
showNotification: false,
|
|
|
|
|
playSound: false,
|
|
|
|
|
),
|
|
|
|
|
foregroundTaskOptions: ForegroundTaskOptions(
|
|
|
|
|
eventAction: ForegroundTaskEventAction.repeat(5000),
|
|
|
|
|
autoRunOnBoot: true,
|
|
|
|
|
autoRunOnMyPackageReplaced: true,
|
|
|
|
|
allowWakeLock: true,
|
|
|
|
|
allowWifiLock: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _startForegroundService() async {
|
|
|
|
|
await FlutterForegroundTask.startService(
|
|
|
|
|
notificationTitle: AppStrings.appName,
|
|
|
|
|
notificationText: 'App is running in foreground',
|
|
|
|
|
callback: startCallback,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize foreground task first
|
|
|
|
|
_initializeForegroundTask();
|
|
|
|
|
|
|
|
|
|
// Register lifecycle callback (e.g., reopen app on detach)
|
|
|
|
|
LifecycleHandler(
|
|
|
|
|
onDetached: () {
|
|
|
|
|
getIt<NativeMethodChannelService>().reopenApp();
|
|
|
|
|
},
|
|
|
|
|
).register();
|
|
|
|
|
|
|
|
|
|
// Start foreground service AFTER initialization
|
|
|
|
|
await _startForegroundService();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -73,6 +26,9 @@ class MyApp extends StatelessWidget {
|
|
|
|
|
return OrientationBuilder(builder: (context, orientation) {
|
|
|
|
|
SizeConfig().init(constraints, orientation);
|
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
|
]);
|
|
|
|
|
return MultiProvider(
|
|
|
|
|
providers: [
|
|
|
|
|
ChangeNotifierProvider<ScreenConfigViewModel>(create: (context) => getIt.get<ScreenConfigViewModel>()),
|
|
|
|
|
|