Skip to content

Commit d51945e

Browse files
author
李卓原
committed
3.2.0
1 parent 2619cd4 commit d51945e

File tree

8 files changed

+30
-25
lines changed

8 files changed

+30
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
* @Description: Update log
77
-->
88

9+
# 3.2.0
10+
- Modify the method name to be more semantic: wp->sw , hp->sh
11+
- Remove the restriction of flutter version
12+
- Modify the return type num to double
13+
914
# 3.1.1
1015
- change readme
1116

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7676
ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings)
7777
7878
ScreenUtil().pixelRatio //Device pixel density
79-
ScreenUtil().screenWidth (sdk>=2.6 : 1.wp) //Device width
80-
ScreenUtil().screenHeight (sdk>=2.6 : 1.hp) //Device height
79+
ScreenUtil().screenWidth (sdk>=2.6 : 1.sw) //Device width
80+
ScreenUtil().screenHeight (sdk>=2.6 : 1.sh) //Device height
8181
ScreenUtil().bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen
8282
ScreenUtil().statusBarHeight //Status bar height , Notch will be higher Unit px
8383
ScreenUtil().textScaleFactor //System font scaling factor
8484
8585
ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px
8686
ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px
8787
88-
0.2.wp //0.2 times the screen width
89-
0.5.hp //50% of screen height
88+
0.2.sw //0.2 times the screen width
89+
0.5.sh //50% of screen height
9090
```
9191

9292
#### Adapt screen size:

README_CN.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7979
ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //适配字体(不会根据系统的“字体大小”辅助选项来进行缩放)
8080
8181
ScreenUtil.pixelRatio //设备的像素密度
82-
ScreenUtil.screenWidth (sdk>=2.6 : 1.wp) //设备宽度
83-
ScreenUtil.screenHeight (sdk>=2.6 : 1.hp) //设备高度
82+
ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度
83+
ScreenUtil.screenHeight (sdk>=2.6 : 1.sh) //设备高度
8484
ScreenUtil.bottomBarHeight //底部安全区距离,适用于全面屏下面有按键的
8585
ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px
8686
ScreenUtil.textScaleFactor //系统字体缩放比例
8787
8888
ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例
8989
ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例
9090
91-
0.2.wp //屏幕宽度的0.2倍
92-
0.5.hp //屏幕高度的50%
91+
0.2.sw //屏幕宽度的0.2倍
92+
0.5.sh //屏幕高度的50%
9393
```
9494

9595

@@ -232,7 +232,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
232232
height: ScreenUtil().setHeight(200),
233233
color: Colors.red,
234234
child: Text(
235-
'我的宽度:${0.5.wp}dp \n'
235+
'我的宽度:${0.5.sw}dp \n'
236236
'我的高度:${ScreenUtil().setHeight(200)}dp',
237237
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
238238
),
@@ -326,8 +326,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
326326
);
327327
print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}');
328328
329-
print('屏幕宽度的0.5:${0.5.wp}');
330-
print('屏幕高度的0.5:${0.5.hp}');
329+
print('屏幕宽度的0.5:${0.5.sw}');
330+
print('屏幕高度的0.5:${0.5.sh}');
331331
}
332332
}
333333

README_PT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7575
ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings)
7676
7777
ScreenUtil.pixelRatio //Device pixel density
78-
ScreenUtil.screenWidth (sdk>=2.6 : 1.wp) //Device width
79-
ScreenUtil.screenHeight (sdk>=2.6 : 1.hp) //Device height
78+
ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //Device width
79+
ScreenUtil.screenHeight (sdk>=2.6 : 1.sh) //Device height
8080
ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen
8181
ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px
8282
ScreenUtil.textScaleFactor //System font scaling factor
8383
8484
ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px
8585
ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px
8686
87-
0.2.wp //0,2 vezes a largura da tela
88-
0.5.hp //50% altura da tela
87+
0.2.sw //0,2 vezes a largura da tela
88+
0.5.sh //50% altura da tela
8989
```
9090

9191
#### Adaptar o tamanho da tela:

example/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class _ExampleWidgetState extends State<ExampleWidget> {
5757
// Using Extensions
5858
Container(
5959
padding: EdgeInsets.all(10.w),
60-
width: 0.5.wp,
60+
width: 0.5.sw,
6161
height: 200.h,
6262
color: Colors.red,
6363
child: Text(
64-
'My width:${0.5.wp}dp \n'
64+
'My width:${0.5.sw}dp \n'
6565
'My height:${200.h}dp',
6666
style: TextStyle(
6767
color: Colors.white,
@@ -152,7 +152,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
152152
print(
153153
'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}');
154154
print('System font scaling:${ScreenUtil().textScaleFactor}');
155-
print('0.5 times the screen width:${0.5.wp}');
156-
print('0.5 times the screen height:${0.5.hp}');
155+
print('0.5 times the screen width:${0.5.sw}');
156+
print('0.5 times the screen height:${0.5.sh}');
157157
}
158158
}

example/lib/main_zh.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
5555
height: ScreenUtil().setHeight(200),
5656
color: Colors.red,
5757
child: Text(
58-
'我的宽度:${0.5.wp}dp \n'
58+
'我的宽度:${0.5.sw}dp \n'
5959
'我的高度:${ScreenUtil().setHeight(200)}dp',
6060
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
6161
),
@@ -149,7 +149,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
149149
);
150150
print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}');
151151

152-
print('屏幕宽度的0.5:${0.5.wp}');
153-
print('屏幕高度的0.5:${0.5.hp}');
152+
print('屏幕宽度的0.5:${0.5.sw}');
153+
print('屏幕高度的0.5:${0.5.sh}');
154154
}
155155
}

lib/size_extension.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ extension SizeExtension on num {
1818

1919
///屏幕宽度的倍数
2020
///Multiple of screen width
21-
double get wp => ScreenUtil().screenWidth * this;
21+
double get sw => ScreenUtil().screenWidth * this;
2222

2323
///屏幕高度的倍数
2424
///Multiple of screen height
25-
double get hp => ScreenUtil().screenHeight * this;
25+
double get sh => ScreenUtil().screenHeight * this;
2626
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_screenutil
22
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
3-
version: 3.1.1
3+
version: 3.2.0
44
homepage: https://github.com/OpenFlutter/flutter_screenutil/tree/beta
55

66
environment:

0 commit comments

Comments
 (0)