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.
		
		
		
		
		
			
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.2 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(message: "Error launching app: $e", source: "reopenApp -> native_method_handler.dart ", type: LogTypeEnum.error);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  void restartApp() async {
 | 
						|
    try {
 | 
						|
      await Restart.restartApp();
 | 
						|
    } catch (e) {
 | 
						|
      loggerService.logError("Error restarting App : $e");
 | 
						|
      loggerService.logToFile(message: "Error restarting app: $e", source: "restartApp -> native_method_handler.dart ", type: LogTypeEnum.error);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 |