Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
lizhuoyuan
2019-08-23 16:39:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aaf3dac491eb3aafeb3ad8c25bb5405e54915589
aaf3dac4
1 parent
8e405a1a
参数同时支持传入 int / double 或者是var size = 100 , var size = 100.0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
example/lib/main_zh.dart
lib/flutter_screenutil.dart
example/lib/main_zh.dart
View file @
aaf3dac
...
...
@@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil.textScaleFactory}
'
);
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
widget
.
title
),
...
...
lib/flutter_screenutil.dart
View file @
aaf3dac
...
...
@@ -93,7 +93,7 @@ class ScreenUtil {
/// Adapted to the device width of the UI Design.
/// Height can also be adapted according to this to ensure no deformation ,
/// if you want a square
setWidth
(
double
width
)
=>
width
*
scaleWidth
;
setWidth
(
num
width
)
=>
width
*
scaleWidth
;
/// 根据UI设计的设备高度适配
/// 当发现UI设计中的一屏显示的与当前样式效果不符合时,
...
...
@@ -103,14 +103,14 @@ class ScreenUtil {
/// 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
/// 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.
///Font size adaptation method
///@param [fontSize] The size of the font on the UI design, in px.
///@param [allowFontScaling]
setSp
(
double
fontSize
)
=>
allowFontScaling
setSp
(
num
fontSize
)
=>
allowFontScaling
?
setWidth
(
fontSize
)
:
setWidth
(
fontSize
)
/
_textScaleFactor
;
}
...
...
Please
register
or
login
to post a comment