提交 aaf3dac4 编写于 作者: L lizhuoyuan

参数同时支持传入 int / double 或者是var size = 100 , var size = 100.0

上级 8e405a1a
...@@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
print( print(
'高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}');
print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}');
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.title), title: Text(widget.title),
......
...@@ -93,7 +93,7 @@ class ScreenUtil { ...@@ -93,7 +93,7 @@ class ScreenUtil {
/// Adapted to the device width of the UI Design. /// Adapted to the device width of the UI Design.
/// Height can also be adapted according to this to ensure no deformation , /// Height can also be adapted according to this to ensure no deformation ,
/// if you want a square /// if you want a square
setWidth(double width) => width * scaleWidth; setWidth(num width) => width * scaleWidth;
/// 根据UI设计的设备高度适配 /// 根据UI设计的设备高度适配
/// 当发现UI设计中的一屏显示的与当前样式效果不符合时, /// 当发现UI设计中的一屏显示的与当前样式效果不符合时,
...@@ -103,14 +103,14 @@ class ScreenUtil { ...@@ -103,14 +103,14 @@ class ScreenUtil {
/// It is recommended to use this method to achieve a high degree of adaptation /// 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 /// 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. /// does not match the current style effect, or if there is a difference in shape.
setHeight(double height) => height * scaleHeight; setHeight(num height) => height * scaleHeight;
///字体大小适配方法 ///字体大小适配方法
///@param [fontSize] UI设计上字体的大小,单位px. ///@param [fontSize] UI设计上字体的大小,单位px.
///Font size adaptation method ///Font size adaptation method
///@param [fontSize] The size of the font on the UI design, in px. ///@param [fontSize] The size of the font on the UI design, in px.
///@param [allowFontScaling] ///@param [allowFontScaling]
setSp(double fontSize) => allowFontScaling setSp(num fontSize) => allowFontScaling
? setWidth(fontSize) ? setWidth(fontSize)
: setWidth(fontSize) / _textScaleFactor; : setWidth(fontSize) / _textScaleFactor;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册