Skip to content

Commit

Permalink
参数同时支持传入 int / double 或者是var size = 100 , var size = 100.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhuoyuan committed Aug 23, 2019
1 parent 8e405a1 commit aaf3dac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/lib/main_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
print(
'高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}');
print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}');

return Scaffold(
appBar: AppBar(
title: Text(widget.title),
Expand Down
6 changes: 3 additions & 3 deletions lib/flutter_screenutil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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
setWidth(double width) => width * scaleWidth;
setWidth(num width) => width * scaleWidth;

/// 根据UI设计的设备高度适配
/// 当发现UI设计中的一屏显示的与当前样式效果不符合时,
Expand All @@ -103,14 +103,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.
setHeight(double height) => height * scaleHeight;
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]
setSp(double fontSize) => allowFontScaling
setSp(num fontSize) => allowFontScaling
? setWidth(fontSize)
: setWidth(fontSize) / _textScaleFactor;
}

0 comments on commit aaf3dac

Please sign in to comment.