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
2020-07-05 15:10:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
79c1ea983d1413d8e3f40ece7aa0e8361d270527
79c1ea98
1 parent
bd7355c0
2.2.0
fix #129
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
9 deletions
CHANGELOG.md
README.md
README_CN.md
README_PT.md
example/lib/main.dart
example/lib/main_zh.dart
lib/size_extension.dart
pubspec.yaml
CHANGELOG.md
View file @
79c1ea9
...
...
@@ -6,6 +6,10 @@
*
@Description: Update log
-->
# 2.2.0
-
add 'wp','hp'. Get the height/width of the screen proportionally
-
For example: 0.5.wp : Half the width of the screen.
# 2.1.0
-
add 'nsp' , you can use 'fontSize: 24.nsp' instead of 'fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: false)'
...
...
README.md
View file @
79c1ea9
...
...
@@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
ScreenUtil
().
setSp
(
24
,
allowFontScalingSelf:
false
)
(
sdk
>=
2.6
:
24
.
nsp
)
//Adapter font(fonts will not scale to respect Text Size accessibility settings)
ScreenUtil
.
pixelRatio
//Device pixel density
ScreenUtil
.
screenWidth
//Device width
ScreenUtil
.
screenHeight
//Device height
ScreenUtil
.
screenWidth
(
sdk
>=
2.6
:
1
.
wp
)
//Device width
ScreenUtil
.
screenHeight
(
sdk
>=
2.6
:
1
.
hp
)
//Device height
ScreenUtil
.
bottomBarHeight
//Bottom safe zone distance, suitable for buttons with full screen
ScreenUtil
.
statusBarHeight
//Status bar height , Notch will be higher Unit px
ScreenUtil
.
textScaleFactor
//System font scaling factor
ScreenUtil
().
scaleWidth
//Ratio of actual width dp to design draft px
ScreenUtil
().
scaleHeight
//Ratio of actual height dp to design draft px
0.2
.
wp
//0.2 times the screen width
0.5
.
hp
//50% of screen width
```
#### Adapt screen size:
...
...
README_CN.md
View file @
79c1ea9
...
...
@@ -78,14 +78,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
ScreenUtil
().
setSp
(
24
,
allowFontScalingSelf:
false
)
(
sdk
>=
2.6
:
24
.
nsp
)
//适配字体(不会根据系统的“字体大小”辅助选项来进行缩放)
ScreenUtil
.
pixelRatio
//设备的像素密度
ScreenUtil
.
screenWidth
//设备宽度
ScreenUtil
.
screenHeight
//设备高度
ScreenUtil
.
screenWidth
(
sdk
>=
2.6
:
1
.
wp
)
//设备宽度
ScreenUtil
.
screenHeight
(
sdk
>=
2.6
:
1
.
hp
)
//设备高度
ScreenUtil
.
bottomBarHeight
//底部安全区距离,适用于全面屏下面有按键的
ScreenUtil
.
statusBarHeight
//状态栏高度 刘海屏会更高 单位px
ScreenUtil
.
textScaleFactor
//系统字体缩放比例
ScreenUtil
().
scaleWidth
// 实际宽度的dp与设计稿px的比例
ScreenUtil
().
scaleHeight
// 实际高度的dp与设计稿px的比例
0.2
.
wp
//屏幕宽度的0.2倍
0.5
.
hp
//屏幕宽度的50%
```
...
...
README_PT.md
View file @
79c1ea9
...
...
@@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
ScreenUtil
().
setSp
(
24
,
allowFontScalingSelf:
false
)
(
sdk
>=
2.6
:
24
.
nsp
)
//Adapter font(fonts will not scale to respect Text Size accessibility settings)
ScreenUtil
.
pixelRatio
//Device pixel density
ScreenUtil
.
screenWidth
//Device width
ScreenUtil
.
screenHeight
//Device height
ScreenUtil
.
screenWidth
(
sdk
>=
2.6
:
1
.
wp
)
//Device width
ScreenUtil
.
screenHeight
(
sdk
>=
2.6
:
1
.
hp
)
//Device height
ScreenUtil
.
bottomBarHeight
//Bottom safe zone distance, suitable for buttons with full screen
ScreenUtil
.
statusBarHeight
//Status bar height , Notch will be higher Unit px
ScreenUtil
.
textScaleFactor
//System font scaling factor
ScreenUtil
().
scaleWidth
//Ratio of actual width dp to design draft px
ScreenUtil
().
scaleHeight
//Ratio of actual height dp to design draft px
0.2
.
wp
//0,2 vezes a largura da tela
0.5
.
hp
//50% da largura da tela
```
#### Adaptar o tamanho da tela:
...
...
example/lib/main.dart
View file @
79c1ea9
...
...
@@ -73,7 +73,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
height:
ScreenUtil
().
setHeight
(
200
),
color:
Colors
.
blue
,
child:
Text
(
'My width:
${
ScreenUtil().setWidth(375)
}
dp
\n
'
'My width:
${
0.5.wp
}
dp
\n
'
'My height:
${ScreenUtil().setHeight(200)}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
...
...
@@ -148,5 +148,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
print
(
'The ratio of height width to the size of the design:
${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'System font scaling:
${ScreenUtil.textScaleFactor}
'
);
print
(
'0.5 times the screen width:
${0.5.wp}
'
);
print
(
'0.5 times the screen height:
${0.5.hp}
'
);
}
}
...
...
example/lib/main_zh.dart
View file @
79c1ea9
...
...
@@ -66,7 +66,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
height:
ScreenUtil
().
setHeight
(
200
),
color:
Colors
.
red
,
child:
Text
(
'我的宽度:
${
ScreenUtil().setWidth(375)
}
dp
\n
'
'我的宽度:
${
0.5.wp
}
dp
\n
'
'我的高度:
${ScreenUtil().setHeight(200)}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
().
setSp
(
24
)),
...
...
@@ -149,5 +149,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
'宽度和字体相对于设计稿放大的比例:
${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}
'
);
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil.textScaleFactor}
'
);
print
(
'屏幕宽度的0.5:
${0.5.wp}
'
);
print
(
'屏幕高度的0.5:
${0.5.hp}
'
);
}
}
...
...
lib/size_extension.dart
View file @
79c1ea9
import
'package:flutter_screenutil/screenutil.dart'
;
extension
SizeExtension
on
num
{
///[ScreenUtil.setWidth]
num
get
w
=>
ScreenUtil
().
setWidth
(
this
);
///[ScreenUtil.setHeight]
num
get
h
=>
ScreenUtil
().
setHeight
(
this
);
///[ScreenUtil.setSp]
num
get
sp
=>
ScreenUtil
().
setSp
(
this
);
///[ScreenUtil.setSp]
num
get
ssp
=>
ScreenUtil
().
setSp
(
this
,
allowFontScalingSelf:
true
);
///[ScreenUtil.setSp]
num
get
nsp
=>
ScreenUtil
().
setSp
(
this
,
allowFontScalingSelf:
false
);
///屏幕宽度的倍数
///Multiple of screen width
num
get
wp
=>
ScreenUtil
.
screenWidth
*
this
;
///屏幕高度的倍数
///Multiple of screen height
num
get
hp
=>
ScreenUtil
.
screenHeight
*
this
;
}
...
...
pubspec.yaml
View file @
79c1ea9
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
2.
1
.0
version
:
2.
2
.0
homepage
:
https://github.com/OpenFlutter/flutter_screenutil
environment
:
...
...
Please
register
or
login
to post a comment