Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
__卓原
flutter_screenutil
提交
aaf3dac4
F
flutter_screenutil
项目概览
__卓原
/
flutter_screenutil
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flutter_screenutil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
aaf3dac4
编写于
8月 23, 2019
作者:
L
lizhuoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
参数同时支持传入 int / double 或者是var size = 100 , var size = 100.0
上级
8e405a1a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
4 deletion
+4
-4
example/lib/main_zh.dart
example/lib/main_zh.dart
+1
-1
lib/flutter_screenutil.dart
lib/flutter_screenutil.dart
+3
-3
未找到文件。
example/lib/main_zh.dart
浏览文件 @
aaf3dac4
...
@@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
print
(
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil.textScaleFactory}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil.textScaleFactory}
'
);
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
Text
(
widget
.
title
),
title:
Text
(
widget
.
title
),
...
...
lib/flutter_screenutil.dart
浏览文件 @
aaf3dac4
...
@@ -93,7 +93,7 @@ class ScreenUtil {
...
@@ -93,7 +93,7 @@ class ScreenUtil {
/// Adapted to the device width of the UI Design.
/// Adapted to the device width of the UI Design.
/// Height can also be adapted according to this to ensure no deformation ,
/// Height can also be adapted according to this to ensure no deformation ,
/// if you want a square
/// if you want a square
setWidth
(
double
width
)
=>
width
*
scaleWidth
;
setWidth
(
num
width
)
=>
width
*
scaleWidth
;
/// 根据UI设计的设备高度适配
/// 根据UI设计的设备高度适配
/// 当发现UI设计中的一屏显示的与当前样式效果不符合时,
/// 当发现UI设计中的一屏显示的与当前样式效果不符合时,
...
@@ -103,14 +103,14 @@ class ScreenUtil {
...
@@ -103,14 +103,14 @@ class ScreenUtil {
/// It is recommended to use this method to achieve a high degree of adaptation
/// It is recommended to use this method to achieve a high degree of adaptation
/// when it is found that one screen in the UI design
/// when it is found that one screen in the UI design
/// does not match the current style effect, or if there is a difference in shape.
/// does not match the current style effect, or if there is a difference in shape.
setHeight
(
double
height
)
=>
height
*
scaleHeight
;
setHeight
(
num
height
)
=>
height
*
scaleHeight
;
///字体大小适配方法
///字体大小适配方法
///@param [fontSize] UI设计上字体的大小,单位px.
///@param [fontSize] UI设计上字体的大小,单位px.
///Font size adaptation method
///Font size adaptation method
///@param [fontSize] The size of the font on the UI design, in px.
///@param [fontSize] The size of the font on the UI design, in px.
///@param [allowFontScaling]
///@param [allowFontScaling]
setSp
(
double
fontSize
)
=>
allowFontScaling
setSp
(
num
fontSize
)
=>
allowFontScaling
?
setWidth
(
fontSize
)
?
setWidth
(
fontSize
)
:
setWidth
(
fontSize
)
/
_textScaleFactor
;
:
setWidth
(
fontSize
)
/
_textScaleFactor
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录