import 'package:flutter/services.dart'; import 'package:hmg_qline/constants/app_constants.dart'; import 'package:hmg_qline/services/logger_service.dart'; import 'package:hmg_qline/utilities/enums.dart'; import 'package:restart_app/restart_app.dart'; abstract class NativeMethodChannelService { void reopenApp(); void restartApp(); } class NativeMethodChannelServiceImp implements NativeMethodChannelService { MethodChannel platform; LoggerService loggerService; NativeMethodChannelServiceImp({required this.platform, required this.loggerService}); @override void reopenApp() async { try { await platform.invokeMethod(AppStrings.openAppNativeFunctionName); } catch (e) { loggerService.logError("Error launching app: $e"); loggerService.logToFile("Error launching app: $e", type: LogTypeEnum.error); } } @override void restartApp() async { try { await Restart.restartApp(); } catch (e) { loggerService.logError("Error restarting App : $e"); loggerService.logToFile("Error restarting App : $e", type: LogTypeEnum.error); } } }