pikapika/lib/basic/config/Proxy.dart

47 lines
1.0 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
/// 代理设置
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
late String _currentProxy;
Future<String?> initProxy() async {
_currentProxy = await method.getProxy();
2022-03-17 03:31:25 +00:00
return null;
2021-09-29 23:57:09 +00:00
}
String currentProxyName() {
return _currentProxy == "" ? "未设置" : _currentProxy;
}
Future<dynamic> inputProxy(BuildContext context) async {
String? input = await displayTextInputDialog(
context,
2021-12-15 04:22:40 +00:00
src: _currentProxy,
title: '代理服务器',
hint: '请输入代理服务器',
desc: " ( 例如 socks5://127.0.0.1:1080/ ) ",
2021-09-29 23:57:09 +00:00
);
if (input != null) {
await method.setProxy(input);
_currentProxy = input;
}
}
2021-11-30 02:23:49 +00:00
Widget proxySetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
2022-03-19 04:12:27 +00:00
title: const Text("代理服务器"),
2021-11-30 02:23:49 +00:00
subtitle: Text(currentProxyName()),
onTap: () async {
await inputProxy(context);
setState(() {});
},
);
},
);
}