From a16e14eba48863d7a0ccecce58ddb3d2f23e2b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8D=93=E5=8E=9F?= Date: Wed, 17 Apr 2019 10:59:22 +0800 Subject: [PATCH] 0.5.2 Change the parameter type from int to double --- CHANGELOG.md | 8 +++++++- README.md | 6 +++--- README_CN.md | 8 ++++---- example/pubspec.lock | 15 +++++++++++---- lib/flutter_screenutil.dart | 10 +++++----- pubspec.yaml | 2 +- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7145498..f7da045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,4 +34,10 @@ setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling ## [0.5.1] - Fix the wrong way of using -It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)` \ No newline at end of file +It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)` + +## [0.5.2] - Change the parameter type from int to double + +setWidth,setHeight,setSp. +for example: +you can use setWidth(100) or setWidth(100.0) \ No newline at end of file diff --git a/README.md b/README.md index 47a801b..6c4f63b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ dependencies: flutter: sdk: flutter # add flutter_ScreenUtil - flutter_screenutil: ^0.4.2 + flutter_screenutil: ^0.5.2 ``` ### Add the following imports to your Dart code: @@ -33,8 +33,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |Property|Type|Default Value|Description| |:---|:---|:---|:---| -|width|int|1080px|The width of the device in the design draft, in px| -|height|int|1920px|The height of the device in the design draft, in px| +|width|double|1080px|The width of the device in the design draft, in px| +|height|double|1920px|The height of the device in the design draft, in px| |allowFontScaling|bool|false|Sets whether the font size is scaled according to the system's "font size" assist option| ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option diff --git a/README_CN.md b/README_CN.md index f2399ee..925dce3 100644 --- a/README_CN.md +++ b/README_CN.md @@ -10,7 +10,7 @@ [README of English](https://github.com/OpenFlutter/flutter_ScreenUtil/blob/master/README.md) -github: https://github.com/OpenFlutter/flutter_ScreenUtil +github: https://github.com/OpenFlutter/flutter_screenutil csdn博客工具介绍:https://blog.csdn.net/u011272795/article/details/82795477 @@ -26,7 +26,7 @@ dependencies: flutter: sdk: flutter # 添加依赖 - flutter_screenutil: ^0.5.0 + flutter_screenutil: ^0.5.2 ``` ### 在每个使用的地方导入包: @@ -38,8 +38,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |属性|类型|默认值|描述| |:---|:---|:---|:---| -|width|int|1080px|设计稿中设备的宽度,单位px| -|height|int|1920px|设计稿中设备的高度,单位px| +|width|double|1080px|设计稿中设备的宽度,单位px| +|height|double|1920px|设计稿中设备的高度,单位px| |allowFontScaling|bool|false|设置字体大小是否根据系统的“字体大小”辅助选项来进行缩放| ### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放 diff --git a/example/pubspec.lock b/example/pubspec.lock index af102e3..1c8a7eb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -74,6 +74,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.2" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.0" quiver: dependency: transitive description: @@ -92,7 +99,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.4.1" + version: "1.5.5" stack_trace: dependency: transitive description: @@ -120,14 +127,14 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.1" + version: "0.2.2" typed_data: dependency: transitive description: @@ -143,4 +150,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.0.0 <3.0.0" + dart: ">=2.1.1-dev.0.0 <3.0.0" diff --git a/lib/flutter_screenutil.dart b/lib/flutter_screenutil.dart index d0ea2fc..bc345ef 100644 --- a/lib/flutter_screenutil.dart +++ b/lib/flutter_screenutil.dart @@ -9,8 +9,8 @@ class ScreenUtil { static ScreenUtil instance = new ScreenUtil(); //设计稿的设备尺寸修改 - int width; - int height; + double width; + double height; bool allowFontScaling; static MediaQueryData _mediaQueryData; @@ -77,19 +77,19 @@ class ScreenUtil { ///根据设计稿的设备宽度适配 ///高度也根据这个来做适配可以保证不变形 - setWidth(int width) => width * scaleWidth; + setWidth(double width) => width * scaleWidth; /// 根据设计稿的设备高度适配 /// 当发现设计稿中的一屏显示的与当前样式效果不符合时, /// 或者形状有差异时,高度适配建议使用此方法 /// 高度适配主要针对想根据设计稿的一屏展示一样的效果 - setHeight(int height) => height * scaleHeight; + setHeight(double height) => height * scaleHeight; ///字体大小适配方法 ///@param fontSize 传入设计稿上字体的px , ///@param allowFontScaling 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 ///@param allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. - setSp(int fontSize) => allowFontScaling + setSp(double fontSize) => allowFontScaling ? setWidth(fontSize) : setWidth(fontSize) / _textScaleFactor; } diff --git a/pubspec.yaml b/pubspec.yaml index 25aec5a..cb3b3b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_screenutil description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models -version: 0.5.1 +version: 0.5.2 author: LiZhuoyuan homepage: https://github.com/OpenFlutter/flutter_ScreenUtil