2024-04-30 23:38:49 +08:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
|
|
import 'proxy_platform_interface.dart';
|
|
|
|
|
|
|
|
|
|
/// An implementation of [ProxyPlatform] that uses method channels.
|
|
|
|
|
class MethodChannelProxy extends ProxyPlatform {
|
|
|
|
|
/// The method channel used to interact with the native platform.
|
|
|
|
|
@visibleForTesting
|
|
|
|
|
final methodChannel = const MethodChannel('proxy');
|
|
|
|
|
|
|
|
|
|
MethodChannelProxy();
|
|
|
|
|
|
|
|
|
|
@override
|
2024-11-09 20:17:57 +08:00
|
|
|
Future<bool?> startProxy(int port, List<String> bypassDomain) async {
|
|
|
|
|
return await methodChannel.invokeMethod<bool>("StartProxy", {
|
|
|
|
|
'port': port,
|
|
|
|
|
'bypassDomain': bypassDomain,
|
|
|
|
|
});
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<bool?> stopProxy() async {
|
2024-11-09 20:17:57 +08:00
|
|
|
return await methodChannel.invokeMethod<bool>("StopProxy");
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
}
|