Showing
8 changed files
with
30 additions
and
25 deletions
| @@ -6,6 +6,11 @@ | @@ -6,6 +6,11 @@ | ||
| 6 | * @Description: Update log | 6 | * @Description: Update log |
| 7 | --> | 7 | --> |
| 8 | 8 | ||
| 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 | + | ||
| 9 | # 3.1.1 | 14 | # 3.1.1 |
| 10 | - change readme | 15 | - change readme |
| 11 | 16 |
| @@ -76,8 +76,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -76,8 +76,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 76 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) | 76 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) |
| 77 | 77 | ||
| 78 | ScreenUtil().pixelRatio //Device pixel density | 78 | 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 | ||
| 81 | ScreenUtil().bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen | 81 | ScreenUtil().bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen |
| 82 | ScreenUtil().statusBarHeight //Status bar height , Notch will be higher Unit px | 82 | ScreenUtil().statusBarHeight //Status bar height , Notch will be higher Unit px |
| 83 | ScreenUtil().textScaleFactor //System font scaling factor | 83 | ScreenUtil().textScaleFactor //System font scaling factor |
| @@ -85,8 +85,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -85,8 +85,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 85 | ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px | 85 | ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px |
| 86 | ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px | 86 | ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px |
| 87 | 87 | ||
| 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 | ||
| 90 | ``` | 90 | ``` |
| 91 | 91 | ||
| 92 | #### Adapt screen size: | 92 | #### Adapt screen size: |
| @@ -79,8 +79,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -79,8 +79,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 79 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //适配字体(不会根据系统的“字体大小”辅助选项来进行缩放) | 79 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //适配字体(不会根据系统的“字体大小”辅助选项来进行缩放) |
| 80 | 80 | ||
| 81 | ScreenUtil.pixelRatio //设备的像素密度 | 81 | 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) //设备高度 | ||
| 84 | ScreenUtil.bottomBarHeight //底部安全区距离,适用于全面屏下面有按键的 | 84 | ScreenUtil.bottomBarHeight //底部安全区距离,适用于全面屏下面有按键的 |
| 85 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px | 85 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px |
| 86 | ScreenUtil.textScaleFactor //系统字体缩放比例 | 86 | ScreenUtil.textScaleFactor //系统字体缩放比例 |
| @@ -88,8 +88,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -88,8 +88,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 88 | ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例 | 88 | ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例 |
| 89 | ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例 | 89 | ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例 |
| 90 | 90 | ||
| 91 | - 0.2.wp //屏幕宽度的0.2倍 | ||
| 92 | - 0.5.hp //屏幕高度的50% | 91 | + 0.2.sw //屏幕宽度的0.2倍 |
| 92 | + 0.5.sh //屏幕高度的50% | ||
| 93 | ``` | 93 | ``` |
| 94 | 94 | ||
| 95 | 95 | ||
| @@ -232,7 +232,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -232,7 +232,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 232 | height: ScreenUtil().setHeight(200), | 232 | height: ScreenUtil().setHeight(200), |
| 233 | color: Colors.red, | 233 | color: Colors.red, |
| 234 | child: Text( | 234 | child: Text( |
| 235 | - '我的宽度:${0.5.wp}dp \n' | 235 | + '我的宽度:${0.5.sw}dp \n' |
| 236 | '我的高度:${ScreenUtil().setHeight(200)}dp', | 236 | '我的高度:${ScreenUtil().setHeight(200)}dp', |
| 237 | style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)), | 237 | style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
| 238 | ), | 238 | ), |
| @@ -326,8 +326,8 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -326,8 +326,8 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 326 | ); | 326 | ); |
| 327 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); | 327 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); |
| 328 | 328 | ||
| 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}'); | ||
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | 333 |
| @@ -75,8 +75,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -75,8 +75,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 75 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) | 75 | ScreenUtil().setSp(24, allowFontScalingSelf: false) (sdk>=2.6 : 24.nsp) //Adapter font(fonts will not scale to respect Text Size accessibility settings) |
| 76 | 76 | ||
| 77 | ScreenUtil.pixelRatio //Device pixel density | 77 | 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 | ||
| 80 | ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen | 80 | ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen |
| 81 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px | 81 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px |
| 82 | ScreenUtil.textScaleFactor //System font scaling factor | 82 | ScreenUtil.textScaleFactor //System font scaling factor |
| @@ -84,8 +84,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | @@ -84,8 +84,8 @@ ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); | ||
| 84 | ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px | 84 | ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px |
| 85 | ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px | 85 | ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px |
| 86 | 86 | ||
| 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 | ||
| 89 | ``` | 89 | ``` |
| 90 | 90 | ||
| 91 | #### Adaptar o tamanho da tela: | 91 | #### Adaptar o tamanho da tela: |
| @@ -57,11 +57,11 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -57,11 +57,11 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 57 | // Using Extensions | 57 | // Using Extensions |
| 58 | Container( | 58 | Container( |
| 59 | padding: EdgeInsets.all(10.w), | 59 | padding: EdgeInsets.all(10.w), |
| 60 | - width: 0.5.wp, | 60 | + width: 0.5.sw, |
| 61 | height: 200.h, | 61 | height: 200.h, |
| 62 | color: Colors.red, | 62 | color: Colors.red, |
| 63 | child: Text( | 63 | child: Text( |
| 64 | - 'My width:${0.5.wp}dp \n' | 64 | + 'My width:${0.5.sw}dp \n' |
| 65 | 'My height:${200.h}dp', | 65 | 'My height:${200.h}dp', |
| 66 | style: TextStyle( | 66 | style: TextStyle( |
| 67 | color: Colors.white, | 67 | color: Colors.white, |
| @@ -152,7 +152,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -152,7 +152,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 152 | print( | 152 | print( |
| 153 | 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}'); | 153 | 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}'); |
| 154 | print('System font scaling:${ScreenUtil().textScaleFactor}'); | 154 | 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}'); | ||
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| @@ -55,7 +55,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -55,7 +55,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 55 | height: ScreenUtil().setHeight(200), | 55 | height: ScreenUtil().setHeight(200), |
| 56 | color: Colors.red, | 56 | color: Colors.red, |
| 57 | child: Text( | 57 | child: Text( |
| 58 | - '我的宽度:${0.5.wp}dp \n' | 58 | + '我的宽度:${0.5.sw}dp \n' |
| 59 | '我的高度:${ScreenUtil().setHeight(200)}dp', | 59 | '我的高度:${ScreenUtil().setHeight(200)}dp', |
| 60 | style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)), | 60 | style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
| 61 | ), | 61 | ), |
| @@ -149,7 +149,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | @@ -149,7 +149,7 @@ class _ExampleWidgetState extends State<ExampleWidget> { | ||
| 149 | ); | 149 | ); |
| 150 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); | 150 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); |
| 151 | 151 | ||
| 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}'); | ||
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| @@ -18,9 +18,9 @@ extension SizeExtension on num { | @@ -18,9 +18,9 @@ extension SizeExtension on num { | ||
| 18 | 18 | ||
| 19 | ///屏幕宽度的倍数 | 19 | ///屏幕宽度的倍数 |
| 20 | ///Multiple of screen width | 20 | ///Multiple of screen width |
| 21 | - double get wp => ScreenUtil().screenWidth * this; | 21 | + double get sw => ScreenUtil().screenWidth * this; |
| 22 | 22 | ||
| 23 | ///屏幕高度的倍数 | 23 | ///屏幕高度的倍数 |
| 24 | ///Multiple of screen height | 24 | ///Multiple of screen height |
| 25 | - double get hp => ScreenUtil().screenHeight * this; | 25 | + double get sh => ScreenUtil().screenHeight * this; |
| 26 | } | 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: 3.1.1 | 3 | +version: 3.2.0 |
| 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil/tree/beta | 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil/tree/beta |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment