import 'dart:async'; import 'dart:io'; import 'dart:isolate'; import 'package:fl_clash/state.dart'; import 'package:flutter/services.dart'; class Service { static Service? _instance; late MethodChannel methodChannel; ReceivePort? receiver; Service._internal() { methodChannel = const MethodChannel("service"); } factory Service() { _instance ??= Service._internal(); return _instance!; } Future init() async { return await methodChannel.invokeMethod("init"); } Future destroy() async { return await methodChannel.invokeMethod("destroy"); } } final service = Platform.isAndroid && !globalState.isVpnService ? Service() : null;