From c7b1efe78530330bf5640eb6a52b3889cef3e5f3 Mon Sep 17 00:00:00 2001 From: Aneesh Rao <66567899+sidrao2006@users.noreply.github.com> Date: Wed, 30 Sep 2020 09:41:36 +0530 Subject: [PATCH 1/5] Add extension on double Replace extension on num with that on double. --- lib/size_extension.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/size_extension.dart b/lib/size_extension.dart index 2ae5a49..9c1cffb 100644 --- a/lib/size_extension.dart +++ b/lib/size_extension.dart @@ -1,6 +1,6 @@ import 'package:flutter_screenutil/screenutil.dart'; -extension SizeExtension on num { +extension SizeExtension on double { ///[ScreenUtil.setWidth] num get w => ScreenUtil().setWidth(this); From f8d57c3d27638873c3d11dde4fe4a3d29f258a1c Mon Sep 17 00:00:00 2001 From: Aneesh Rao <66567899+sidrao2006@users.noreply.github.com> Date: Wed, 30 Sep 2020 09:50:45 +0530 Subject: [PATCH 2/5] Change type annotations Update type annotations for stronger type checks and prevent confusion. --- lib/size_extension.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/size_extension.dart b/lib/size_extension.dart index 9c1cffb..952a35d 100644 --- a/lib/size_extension.dart +++ b/lib/size_extension.dart @@ -2,25 +2,25 @@ import 'package:flutter_screenutil/screenutil.dart'; extension SizeExtension on double { ///[ScreenUtil.setWidth] - num get w => ScreenUtil().setWidth(this); + double get w => ScreenUtil().setWidth(this); ///[ScreenUtil.setHeight] - num get h => ScreenUtil().setHeight(this); + double get h => ScreenUtil().setHeight(this); ///[ScreenUtil.setSp] - num get sp => ScreenUtil().setSp(this); + double get sp => ScreenUtil().setSp(this); ///[ScreenUtil.setSp] - num get ssp => ScreenUtil().setSp(this, allowFontScalingSelf: true); + double get ssp => ScreenUtil().setSp(this, allowFontScalingSelf: true); ///[ScreenUtil.setSp] - num get nsp => ScreenUtil().setSp(this, allowFontScalingSelf: false); + double get nsp => ScreenUtil().setSp(this, allowFontScalingSelf: false); ///屏幕宽度的倍数 ///Multiple of screen width - num get wp => ScreenUtil().screenWidth * this; + double get wp => ScreenUtil().screenWidth * this; ///屏幕高度的倍数 ///Multiple of screen height - num get hp => ScreenUtil().screenHeight * this; + double get hp => ScreenUtil().screenHeight * this; } From 68b9874d045e4f548209a82cbfbe37f903c93092 Mon Sep 17 00:00:00 2001 From: Aneesh Rao <66567899+sidrao2006@users.noreply.github.com> Date: Wed, 30 Sep 2020 09:51:00 +0530 Subject: [PATCH 3/5] Revert "Add extension on double" --- lib/size_extension.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/size_extension.dart b/lib/size_extension.dart index 9c1cffb..2ae5a49 100644 --- a/lib/size_extension.dart +++ b/lib/size_extension.dart @@ -1,6 +1,6 @@ import 'package:flutter_screenutil/screenutil.dart'; -extension SizeExtension on double { +extension SizeExtension on num { ///[ScreenUtil.setWidth] num get w => ScreenUtil().setWidth(this); From 85fe35cbf1d634a2e2ac2be9cf14c5c71f707f70 Mon Sep 17 00:00:00 2001 From: Aneesh Rao <66567899+sidrao2006@users.noreply.github.com> Date: Wed, 30 Sep 2020 09:59:37 +0530 Subject: [PATCH 4/5] Update type annotations --- lib/screenutil.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/screenutil.dart b/lib/screenutil.dart index cb605cd..0feec6d 100644 --- a/lib/screenutil.dart +++ b/lib/screenutil.dart @@ -97,7 +97,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 - num setWidth(num width) => width * scaleWidth; + double setWidth(num width) => width * scaleWidth; /// 根据UI设计的设备高度适配 /// 当发现UI设计中的一屏显示的与当前样式效果不符合时, @@ -107,14 +107,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. - num setHeight(num height) => height * scaleHeight; + double 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] - num setSp(num fontSize, {bool allowFontScalingSelf}) => + double setSp(num fontSize, {bool allowFontScalingSelf}) => allowFontScalingSelf == null ? (allowFontScaling ? (fontSize * scaleText) From c35e4b96405bd8afa084c38ac695f9cf11f1aef1 Mon Sep 17 00:00:00 2001 From: Aneesh Rao Date: Wed, 30 Sep 2020 11:06:33 +0530 Subject: [PATCH 5/5] dart doesn't use @param --- lib/screenutil.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/screenutil.dart b/lib/screenutil.dart index cb605cd..0d9d0ab 100644 --- a/lib/screenutil.dart +++ b/lib/screenutil.dart @@ -110,10 +110,10 @@ class ScreenUtil { num setHeight(num height) => height * scaleHeight; ///字体大小适配方法 - ///@param [fontSize] UI设计上字体的大小,单位px. + ///- [fontSize] UI设计上字体的大小,单位px. ///Font size adaptation method - ///@param [fontSize] The size of the font on the UI design, in px. - ///@param [allowFontScaling] + ///- [fontSize] The size of the font on the UI design, in px. + ///- [allowFontScaling] num setSp(num fontSize, {bool allowFontScalingSelf}) => allowFontScalingSelf == null ? (allowFontScaling