Showing
2 changed files
with
4 additions
and
4 deletions
| @@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> { | ||
| 48 | print( | 48 | print( |
| 49 | '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | 49 | '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); |
| 50 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); | 50 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); |
| 51 | - | 51 | + |
| 52 | return Scaffold( | 52 | return Scaffold( |
| 53 | appBar: AppBar( | 53 | appBar: AppBar( |
| 54 | title: Text(widget.title), | 54 | title: Text(widget.title), |
| @@ -93,7 +93,7 @@ class ScreenUtil { | @@ -93,7 +93,7 @@ class ScreenUtil { | ||
| 93 | /// Adapted to the device width of the UI Design. | 93 | /// Adapted to the device width of the UI Design. |
| 94 | /// Height can also be adapted according to this to ensure no deformation , | 94 | /// Height can also be adapted according to this to ensure no deformation , |
| 95 | /// if you want a square | 95 | /// if you want a square |
| 96 | - setWidth(double width) => width * scaleWidth; | 96 | + setWidth(num width) => width * scaleWidth; |
| 97 | 97 | ||
| 98 | /// 根据UI设计的设备高度适配 | 98 | /// 根据UI设计的设备高度适配 |
| 99 | /// 当发现UI设计中的一屏显示的与当前样式效果不符合时, | 99 | /// 当发现UI设计中的一屏显示的与当前样式效果不符合时, |
| @@ -103,14 +103,14 @@ class ScreenUtil { | @@ -103,14 +103,14 @@ class ScreenUtil { | ||
| 103 | /// It is recommended to use this method to achieve a high degree of adaptation | 103 | /// It is recommended to use this method to achieve a high degree of adaptation |
| 104 | /// when it is found that one screen in the UI design | 104 | /// when it is found that one screen in the UI design |
| 105 | /// does not match the current style effect, or if there is a difference in shape. | 105 | /// does not match the current style effect, or if there is a difference in shape. |
| 106 | - setHeight(double height) => height * scaleHeight; | 106 | + setHeight(num height) => height * scaleHeight; |
| 107 | 107 | ||
| 108 | ///字体大小适配方法 | 108 | ///字体大小适配方法 |
| 109 | ///@param [fontSize] UI设计上字体的大小,单位px. | 109 | ///@param [fontSize] UI设计上字体的大小,单位px. |
| 110 | ///Font size adaptation method | 110 | ///Font size adaptation method |
| 111 | ///@param [fontSize] The size of the font on the UI design, in px. | 111 | ///@param [fontSize] The size of the font on the UI design, in px. |
| 112 | ///@param [allowFontScaling] | 112 | ///@param [allowFontScaling] |
| 113 | - setSp(double fontSize) => allowFontScaling | 113 | + setSp(num fontSize) => allowFontScaling |
| 114 | ? setWidth(fontSize) | 114 | ? setWidth(fontSize) |
| 115 | : setWidth(fontSize) / _textScaleFactor; | 115 | : setWidth(fontSize) / _textScaleFactor; |
| 116 | } | 116 | } |
-
Please register or login to post a comment