LiZhuoyuan

2.2.0

fix #129
@@ -5,7 +5,11 @@ @@ -5,7 +5,11 @@
5 * @LastEditTime: 2020年6月20日 11:20:02 5 * @LastEditTime: 2020年6月20日 11:20:02
6 * @Description: Update log 6 * @Description: Update log
7 --> 7 -->
8 - 8 +
  9 +# 2.2.0
  10 +- add 'wp','hp'. Get the height/width of the screen proportionally
  11 +- For example: 0.5.wp : Half the width of the screen.
  12 +
9 # 2.1.0 13 # 2.1.0
10 - add 'nsp' , you can use 'fontSize: 24.nsp' instead of 'fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: false)' 14 - add 'nsp' , you can use 'fontSize: 24.nsp' instead of 'fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: false)'
11 15
@@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); / @@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
74 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) 74 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings)
75 75
76 ScreenUtil.pixelRatio //Device pixel density 76 ScreenUtil.pixelRatio //Device pixel density
77 - ScreenUtil.screenWidth //Device width  
78 - ScreenUtil.screenHeight //Device height 77 + ScreenUtil.screenWidth (sdk>=2.6 : 1.wp) //Device width
  78 + ScreenUtil.screenHeight (sdk>=2.6 : 1.hp) //Device height
79 ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen 79 ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen
80 ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px 80 ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px
81 ScreenUtil.textScaleFactor //System font scaling factor 81 ScreenUtil.textScaleFactor //System font scaling factor
82 82
83 ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px 83 ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px
84 ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px 84 ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px
  85 +
  86 + 0.2.wp //0.2 times the screen width
  87 + 0.5.hp //50% of screen width
85 ``` 88 ```
86 89
87 #### Adapt screen size: 90 #### Adapt screen size:
@@ -78,14 +78,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); / @@ -78,14 +78,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
78 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //适配字体(不会根据系统的“字体大小”辅助选项来进行缩放) 78 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //适配字体(不会根据系统的“字体大小”辅助选项来进行缩放)
79 79
80 ScreenUtil.pixelRatio //设备的像素密度 80 ScreenUtil.pixelRatio //设备的像素密度
81 - ScreenUtil.screenWidth //设备宽度  
82 - ScreenUtil.screenHeight //设备高度 81 + ScreenUtil.screenWidth (sdk>=2.6 : 1.wp) //设备宽度
  82 + ScreenUtil.screenHeight (sdk>=2.6 : 1.hp) //设备高度
83 ScreenUtil.bottomBarHeight //底部安全区距离,适用于全面屏下面有按键的 83 ScreenUtil.bottomBarHeight //底部安全区距离,适用于全面屏下面有按键的
84 ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px 84 ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px
85 ScreenUtil.textScaleFactor //系统字体缩放比例 85 ScreenUtil.textScaleFactor //系统字体缩放比例
86 86
87 ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例 87 ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例
88 ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例 88 ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例
  89 +
  90 + 0.2.wp //屏幕宽度的0.2倍
  91 + 0.5.hp //屏幕宽度的50%
89 ``` 92 ```
90 93
91 94
@@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); / @@ -74,14 +74,17 @@ ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); /
74 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) 74 ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings)
75 75
76 ScreenUtil.pixelRatio //Device pixel density 76 ScreenUtil.pixelRatio //Device pixel density
77 - ScreenUtil.screenWidth //Device width  
78 - ScreenUtil.screenHeight //Device height 77 + ScreenUtil.screenWidth (sdk>=2.6 : 1.wp) //Device width
  78 + ScreenUtil.screenHeight (sdk>=2.6 : 1.hp) //Device height
79 ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen 79 ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen
80 ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px 80 ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px
81 ScreenUtil.textScaleFactor //System font scaling factor 81 ScreenUtil.textScaleFactor //System font scaling factor
82 82
83 ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px 83 ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px
84 ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px 84 ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px
  85 +
  86 + 0.2.wp //0,2 vezes a largura da tela
  87 + 0.5.hp //50% da largura da tela
85 ``` 88 ```
86 89
87 #### Adaptar o tamanho da tela: 90 #### Adaptar o tamanho da tela:
@@ -73,7 +73,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { @@ -73,7 +73,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
73 height: ScreenUtil().setHeight(200), 73 height: ScreenUtil().setHeight(200),
74 color: Colors.blue, 74 color: Colors.blue,
75 child: Text( 75 child: Text(
76 - 'My width:${ScreenUtil().setWidth(375)}dp \n' 76 + 'My width:${0.5.wp}dp \n'
77 'My height:${ScreenUtil().setHeight(200)}dp', 77 'My height:${ScreenUtil().setHeight(200)}dp',
78 style: TextStyle( 78 style: TextStyle(
79 color: Colors.white, 79 color: Colors.white,
@@ -148,5 +148,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { @@ -148,5 +148,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
148 print( 148 print(
149 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); 149 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}');
150 print('System font scaling:${ScreenUtil.textScaleFactor}'); 150 print('System font scaling:${ScreenUtil.textScaleFactor}');
  151 + print('0.5 times the screen width:${0.5.wp}');
  152 + print('0.5 times the screen height:${0.5.hp}');
151 } 153 }
152 } 154 }
@@ -66,7 +66,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { @@ -66,7 +66,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
66 height: ScreenUtil().setHeight(200), 66 height: ScreenUtil().setHeight(200),
67 color: Colors.red, 67 color: Colors.red,
68 child: Text( 68 child: Text(
69 - '我的宽度:${ScreenUtil().setWidth(375)}dp \n' 69 + '我的宽度:${0.5.wp}dp \n'
70 '我的高度:${ScreenUtil().setHeight(200)}dp', 70 '我的高度:${ScreenUtil().setHeight(200)}dp',
71 style: TextStyle( 71 style: TextStyle(
72 color: Colors.white, fontSize: ScreenUtil().setSp(24)), 72 color: Colors.white, fontSize: ScreenUtil().setSp(24)),
@@ -149,5 +149,8 @@ class _ExampleWidgetState extends State<ExampleWidget> { @@ -149,5 +149,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
149 '宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); 149 '宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}');
150 print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); 150 print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}');
151 print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'); 151 print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}');
  152 +
  153 + print('屏幕宽度的0.5:${0.5.wp}');
  154 + print('屏幕高度的0.5:${0.5.hp}');
152 } 155 }
153 } 156 }
1 import 'package:flutter_screenutil/screenutil.dart'; 1 import 'package:flutter_screenutil/screenutil.dart';
2 2
3 extension SizeExtension on num { 3 extension SizeExtension on num {
  4 + ///[ScreenUtil.setWidth]
4 num get w => ScreenUtil().setWidth(this); 5 num get w => ScreenUtil().setWidth(this);
5 6
  7 + ///[ScreenUtil.setHeight]
6 num get h => ScreenUtil().setHeight(this); 8 num get h => ScreenUtil().setHeight(this);
7 9
  10 + ///[ScreenUtil.setSp]
8 num get sp => ScreenUtil().setSp(this); 11 num get sp => ScreenUtil().setSp(this);
9 12
  13 + ///[ScreenUtil.setSp]
10 num get ssp => ScreenUtil().setSp(this, allowFontScalingSelf: true); 14 num get ssp => ScreenUtil().setSp(this, allowFontScalingSelf: true);
11 15
  16 + ///[ScreenUtil.setSp]
12 num get nsp => ScreenUtil().setSp(this, allowFontScalingSelf: false); 17 num get nsp => ScreenUtil().setSp(this, allowFontScalingSelf: false);
  18 +
  19 + ///屏幕宽度的倍数
  20 + ///Multiple of screen width
  21 + num get wp => ScreenUtil.screenWidth * this;
  22 +
  23 + ///屏幕高度的倍数
  24 + ///Multiple of screen height
  25 + num get hp => ScreenUtil.screenHeight * this;
13 } 26 }
1 name: flutter_screenutil 1 name: flutter_screenutil
2 description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models 2 description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
3 -version: 2.1.0 3 +version: 2.2.0
4 homepage: https://github.com/OpenFlutter/flutter_screenutil 4 homepage: https://github.com/OpenFlutter/flutter_screenutil
5 5
6 environment: 6 environment: