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.
HMG_QLine/lib/utilities/native_method_handler.dart

39 lines
1.1 KiB
Dart

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);
}
}
}