Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
F
flutter_clx_base
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
flutter_clx_base
Commits
2c96b817
提交
2c96b817
authored
1月 03, 2025
作者:
史晓晨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:①平台信息工具类②web平台不设置代理
上级
8f51d6c0
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
46 行增加
和
21 行删除
+46
-21
proxy.dart
lib/api/proxy.dart
+21
-20
platform_utils.dart
lib/utils/platform_utils.dart
+23
-0
my_refresh_list_public.dart
lib/widget/my_refresh_list_public.dart
+2
-1
没有找到文件。
lib/api/proxy.dart
浏览文件 @
2c96b817
...
...
@@ -2,6 +2,7 @@ import 'dart:io';
import
'package:flutter/material.dart'
;
import
'package:flutter_clx_base/flutter_clx_base.dart'
;
import
'package:flutter_clx_base/utils/platform_utils.dart'
;
import
'base_dio.dart'
;
...
...
@@ -13,26 +14,26 @@ bool setProxyFlag = false; // 设置代理标识 true 设置 false 不设置
/// dio 设置代理uri
void
setProxyUri
(
Dio
?
dio
,
bool
isProdEnv
)
{
setProxyFlag
=
!
isProdEnv
;
//生产环境不设置代理
if
(!
setProxyFlag
)
return
;
if
(!
setProxyFlag
||
PlatformUtils
.
isWeb
)
return
;
String
?
proxyIP
=
SpUtil
.
getString
(
spProxyIp
);
String
?
proxyPort
=
SpUtil
.
getString
(
spProxyPort
);
//
(dio?.httpClientAdapter as IOHttpClientAdapter?)?.createHttpClient = () {
//
HttpClient client = HttpClient();
//
// 是否设置代理:非生产环境,开启代理后,设置代理
//
bool isSetProxy = setProxyFlag &&
//
proxyIP != null &&
//
proxyIP.isNotEmpty &&
//
proxyPort != null &&
//
proxyPort.isNotEmpty &&
//
SpUtil.getBool(spSwitchProxy) == true;
//
if (isSetProxy) {
//
client.findProxy = (uri) => "PROXY $proxyIP:$proxyPort";
//
client.badCertificateCallback =
//
(X509Certificate cert, String host, int port) => true;
//
}
//
return client;
//
};
(
dio
?.
httpClientAdapter
as
IOHttpClientAdapter
?)?.
createHttpClient
=
()
{
HttpClient
client
=
HttpClient
();
// 是否设置代理:非生产环境,开启代理后,设置代理
bool
isSetProxy
=
setProxyFlag
&&
proxyIP
!=
null
&&
proxyIP
.
isNotEmpty
&&
proxyPort
!=
null
&&
proxyPort
.
isNotEmpty
&&
SpUtil
.
getBool
(
spSwitchProxy
)
==
true
;
if
(
isSetProxy
)
{
client
.
findProxy
=
(
uri
)
=>
"PROXY
$proxyIP
:
$proxyPort
"
;
client
.
badCertificateCallback
=
(
X509Certificate
cert
,
String
host
,
int
port
)
=>
true
;
}
return
client
;
};
}
/// 设置代理widget
...
...
@@ -102,11 +103,10 @@ setProxyDialog(context) {
spProxyIp
,
ipController
.
value
.
text
.
toString
().
trim
());
SpUtil
.
putString
(
spProxyPort
,
portController
.
value
.
text
.
toString
().
trim
());
// 延迟1s 退出,修复保存失败问题
// 延迟1s 退出,修复保存失败问题
Future
.
delayed
(
const
Duration
(
seconds:
1
),
()
{
exit
(
0
);
});
},
child:
Container
(
margin:
const
EdgeInsets
.
only
(
...
...
@@ -160,7 +160,8 @@ Widget _textFieldItem({title, controller}) {
child:
TextField
(
maxLines:
1
,
controller:
controller
,
keyboardType:
const
TextInputType
.
numberWithOptions
(
decimal:
true
),
keyboardType:
const
TextInputType
.
numberWithOptions
(
decimal:
true
),
decoration:
const
InputDecoration
(
counterText:
""
,
border:
InputBorder
.
none
,
//去掉下划线
...
...
lib/utils/platform_utils.dart
0 → 100644
浏览文件 @
2c96b817
import
'dart:io'
;
import
'package:flutter/foundation.dart'
;
/// 平台信息
class
PlatformUtils
{
static
bool
_isWeb
()
{
return
kIsWeb
==
true
;
}
static
bool
_isAndroid
()
{
return
_isWeb
()
?
false
:
Platform
.
isAndroid
;
}
static
bool
_isIOS
()
{
return
_isWeb
()
?
false
:
Platform
.
isIOS
;
}
static
bool
get
isWeb
=>
_isWeb
();
static
bool
get
isAndroid
=>
_isAndroid
();
static
bool
get
isIOS
=>
_isIOS
();
}
lib/widget/my_refresh_list_public.dart
浏览文件 @
2c96b817
...
...
@@ -2,6 +2,7 @@ import 'dart:io';
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_clx_base/utils/platform_utils.dart'
;
import
'state_layout.dart'
;
...
...
@@ -285,7 +286,7 @@ class MyBehavior extends ScrollBehavior {
@override
Widget
buildOverscrollIndicator
(
BuildContext
context
,
Widget
child
,
ScrollableDetails
details
)
{
if
(
Platform
.
isAndroid
||
Platform
.
isFuchsia
)
{
if
(
Platform
Utils
.
isAndroid
)
{
return
child
;
}
else
{
return
super
.
buildOverscrollIndicator
(
context
,
child
,
details
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论