Showing
6 changed files
with
169 additions
and
113 deletions
| 1 | -# Generated by pub on 2019-06-24 14:51:33.826233. | ||
| 2 | -async:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.1.0/lib/ | ||
| 3 | -boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/ | ||
| 4 | -charcode:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/ | ||
| 5 | -collection:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/ | 1 | +# Generated by pub on 2019-08-23 16:15:58.801584. |
| 2 | +async:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.2.0/lib/ | ||
| 3 | +boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.4/lib/ | ||
| 4 | +charcode:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.1.2/lib/ | ||
| 5 | +collection:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11/lib/ | ||
| 6 | flutter:file:///D:/flutter/packages/flutter/lib/ | 6 | flutter:file:///D:/flutter/packages/flutter/lib/ |
| 7 | flutter_test:file:///D:/flutter/packages/flutter_test/lib/ | 7 | flutter_test:file:///D:/flutter/packages/flutter_test/lib/ |
| 8 | -matcher:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.5/lib/ | ||
| 9 | -meta:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/ | ||
| 10 | -path:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib/ | ||
| 11 | -pedantic:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.5.0/lib/ | ||
| 12 | -quiver:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.2/lib/ | 8 | +matcher:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.5/lib/ |
| 9 | +meta:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.6/lib/ | ||
| 10 | +path:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.2/lib/ | ||
| 11 | +pedantic:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/pedantic-1.7.0/lib/ | ||
| 12 | +quiver:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.3/lib/ | ||
| 13 | sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/ | 13 | sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/ |
| 14 | -source_span:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/ | ||
| 15 | -stack_trace:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/ | ||
| 16 | -stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/ | ||
| 17 | -string_scanner:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/ | ||
| 18 | -term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/ | ||
| 19 | -test_api:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.4/lib/ | ||
| 20 | -typed_data:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/ | ||
| 21 | -vector_math:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/ | 14 | +source_span:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.5.5/lib/ |
| 15 | +stack_trace:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3/lib/ | ||
| 16 | +stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-2.0.0/lib/ | ||
| 17 | +string_scanner:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.4/lib/ | ||
| 18 | +term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.1.0/lib/ | ||
| 19 | +test_api:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/test_api-0.2.5/lib/ | ||
| 20 | +typed_data:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6/lib/ | ||
| 21 | +vector_math:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.0.8/lib/ | ||
| 22 | flutter_screenutil:lib/ | 22 | flutter_screenutil:lib/ |
| 1 | -## [0.0.1] - first version | 1 | +<!-- |
| 2 | + * @Author: zhuoyuan93@gmail.com | ||
| 3 | + * @Date: 2018-10-16 19:43:03 | ||
| 4 | + * @LastEditors: zhuoyuan93@gmail.com | ||
| 5 | + * @LastEditTime: 2019-08-23 16:26:24 | ||
| 6 | + * @Description: Update log | ||
| 7 | + --> | ||
| 2 | 8 | ||
| 3 | -## [0.2.2] - Fixed bug when releasing | 9 | +# 0.0.1 |
| 4 | 10 | ||
| 5 | -## [0.2.2] - Optimize documentation | 11 | +- first version |
| 6 | 12 | ||
| 7 | -## [0.3.0] - Add font size adaptation | 13 | +# 0.0.2 |
| 8 | 14 | ||
| 9 | -## [0.3.0] - Perfect documentation | ||
| 10 | -Width is enlarged relative to the design draft => The ratio of font and width to the size of the design | ||
| 11 | -Height is enlarged relative to the design draft => The ratio of height width to the size of the design | 15 | +- Fixed bug when releasing |
| 12 | 16 | ||
| 13 | -## [0.4.0] - Optimize font adaptation method | 17 | +# 0.2.2 |
| 14 | 18 | ||
| 15 | -## [0.4.1] - Fix font adaptation issues | 19 | +- Optimize documentation |
| 16 | 20 | ||
| 17 | -## [0.4.2] - add two Properties | 21 | +# 0.3.0 |
| 18 | 22 | ||
| 19 | - ///Current device width dp <br/> | ||
| 20 | - ///当前设备宽度 dp <br/> | ||
| 21 | - ScreenUtil.screenWidthDp | 23 | +- Add font size adaptation |
| 22 | 24 | ||
| 23 | - ///Current device height dp <br/> | ||
| 24 | - ///当前设备高度 dp <br/> | ||
| 25 | - ScreenUtil.screenHeightDp | 25 | +# 0.3.1 |
| 26 | 26 | ||
| 27 | -## [0.4.2] - Modify the font to change with the system zoom mode. The default value is false. | 27 | +- Perfect documentation |
| 28 | +- Width is enlarged relative to the design draft => The ratio of font and width to the size of the design | ||
| 29 | +- Height is enlarged relative to the design draft => The ratio of height width to the size of the design | ||
| 28 | 30 | ||
| 29 | -setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling | ||
| 30 | - ? setWidth(fontSize) * _textScaleFactor | ||
| 31 | - : setWidth(fontSize); | 31 | +# 0.4.0 |
| 32 | 32 | ||
| 33 | -## [0.4.4] - Fix bugs that default fonts change with the system | 33 | +- Optimize font adaptation method |
| 34 | 34 | ||
| 35 | -## [0.5.1] - Fix the wrong way of using | 35 | +# 0.4.1 |
| 36 | 36 | ||
| 37 | -It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)` | 37 | +- Fix font adaptation issues |
| 38 | 38 | ||
| 39 | -## [0.5.2] - Change the parameter type from int to double | 39 | +# 0.4.2 |
| 40 | 40 | ||
| 41 | -setWidth,setHeight,setSp. | ||
| 42 | -for example: | ||
| 43 | -you can use setWidth(100) or setWidth(100.0) | 41 | +- add two Properties |
| 42 | +- ///Current device width dp | ||
| 43 | +- ///当前设备宽度 dp | ||
| 44 | +- ScreenUtil.screenWidthDp | ||
| 44 | 45 | ||
| 45 | -## [0.5.3] - Change the units of statusBarHeight and bottomBarHeight to dp | ||
| 46 | +- ///Current device height dp | ||
| 47 | +- ///当前设备高度 dp | ||
| 48 | +- ScreenUtil.screenHeightDp | ||
| 49 | + | ||
| 50 | +# 0.4.3 | ||
| 51 | + | ||
| 52 | +- Modify the font to change with the system zoom mode. The default value is false. | ||
| 53 | + | ||
| 54 | +- setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling | ||
| 55 | +? setWidth(fontSize) \* \_textScaleFactor | ||
| 56 | +: setWidth(fontSize); | ||
| 57 | + | ||
| 58 | +# 0.4.4 | ||
| 59 | + | ||
| 60 | +- Fix bugs that default fonts change with the system | ||
| 61 | + | ||
| 62 | +# 0.5.1 | ||
| 63 | + | ||
| 64 | +- Fix the wrong way of using | ||
| 65 | + | ||
| 66 | +- It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)` | ||
| 67 | + | ||
| 68 | +# 0.5.2 | ||
| 69 | + | ||
| 70 | +- Change the parameter type from int to double | ||
| 71 | + | ||
| 72 | +- setWidth,setHeight,setSp. for example: you can use setWidth(100) or setWidth(100.0) | ||
| 73 | + | ||
| 74 | +# 0.5.3 | ||
| 75 | + | ||
| 76 | +- Change the units of statusBarHeight and bottomBarHeight to dp | ||
| 77 | + | ||
| 78 | +# 0.6.0 | ||
| 79 | + | ||
| 80 | +- Completing comments , adding English commentsWelcome to add, correct |
| 1 | # Generated by pub | 1 | # Generated by pub |
| 2 | -# See https://www.dartlang.org/tools/pub/glossary#lockfile | 2 | +# See https://dart.dev/tools/pub/glossary#lockfile |
| 3 | packages: | 3 | packages: |
| 4 | async: | 4 | async: |
| 5 | dependency: transitive | 5 | dependency: transitive |
| 6 | description: | 6 | description: |
| 7 | name: async | 7 | name: async |
| 8 | - url: "https://pub.dartlang.org" | 8 | + url: "https://pub.flutter-io.cn" |
| 9 | source: hosted | 9 | source: hosted |
| 10 | - version: "2.1.0" | 10 | + version: "2.2.0" |
| 11 | boolean_selector: | 11 | boolean_selector: |
| 12 | dependency: transitive | 12 | dependency: transitive |
| 13 | description: | 13 | description: |
| 14 | name: boolean_selector | 14 | name: boolean_selector |
| 15 | - url: "https://pub.dartlang.org" | 15 | + url: "https://pub.flutter-io.cn" |
| 16 | source: hosted | 16 | source: hosted |
| 17 | version: "1.0.4" | 17 | version: "1.0.4" |
| 18 | charcode: | 18 | charcode: |
| 19 | dependency: transitive | 19 | dependency: transitive |
| 20 | description: | 20 | description: |
| 21 | name: charcode | 21 | name: charcode |
| 22 | - url: "https://pub.dartlang.org" | 22 | + url: "https://pub.flutter-io.cn" |
| 23 | source: hosted | 23 | source: hosted |
| 24 | version: "1.1.2" | 24 | version: "1.1.2" |
| 25 | collection: | 25 | collection: |
| 26 | dependency: transitive | 26 | dependency: transitive |
| 27 | description: | 27 | description: |
| 28 | name: collection | 28 | name: collection |
| 29 | - url: "https://pub.dartlang.org" | 29 | + url: "https://pub.flutter-io.cn" |
| 30 | source: hosted | 30 | source: hosted |
| 31 | version: "1.14.11" | 31 | version: "1.14.11" |
| 32 | cupertino_icons: | 32 | cupertino_icons: |
| 33 | dependency: "direct main" | 33 | dependency: "direct main" |
| 34 | description: | 34 | description: |
| 35 | name: cupertino_icons | 35 | name: cupertino_icons |
| 36 | - url: "https://pub.dartlang.org" | 36 | + url: "https://pub.flutter-io.cn" |
| 37 | source: hosted | 37 | source: hosted |
| 38 | version: "0.1.2" | 38 | version: "0.1.2" |
| 39 | flutter: | 39 | flutter: |
| @@ -47,7 +47,7 @@ packages: | @@ -47,7 +47,7 @@ packages: | ||
| 47 | path: ".." | 47 | path: ".." |
| 48 | relative: true | 48 | relative: true |
| 49 | source: path | 49 | source: path |
| 50 | - version: "0.5.3" | 50 | + version: "0.6.0" |
| 51 | flutter_test: | 51 | flutter_test: |
| 52 | dependency: "direct dev" | 52 | dependency: "direct dev" |
| 53 | description: flutter | 53 | description: flutter |
| @@ -57,37 +57,37 @@ packages: | @@ -57,37 +57,37 @@ packages: | ||
| 57 | dependency: transitive | 57 | dependency: transitive |
| 58 | description: | 58 | description: |
| 59 | name: matcher | 59 | name: matcher |
| 60 | - url: "https://pub.dartlang.org" | 60 | + url: "https://pub.flutter-io.cn" |
| 61 | source: hosted | 61 | source: hosted |
| 62 | version: "0.12.5" | 62 | version: "0.12.5" |
| 63 | meta: | 63 | meta: |
| 64 | dependency: transitive | 64 | dependency: transitive |
| 65 | description: | 65 | description: |
| 66 | name: meta | 66 | name: meta |
| 67 | - url: "https://pub.dartlang.org" | 67 | + url: "https://pub.flutter-io.cn" |
| 68 | source: hosted | 68 | source: hosted |
| 69 | version: "1.1.6" | 69 | version: "1.1.6" |
| 70 | path: | 70 | path: |
| 71 | dependency: transitive | 71 | dependency: transitive |
| 72 | description: | 72 | description: |
| 73 | name: path | 73 | name: path |
| 74 | - url: "https://pub.dartlang.org" | 74 | + url: "https://pub.flutter-io.cn" |
| 75 | source: hosted | 75 | source: hosted |
| 76 | version: "1.6.2" | 76 | version: "1.6.2" |
| 77 | pedantic: | 77 | pedantic: |
| 78 | dependency: transitive | 78 | dependency: transitive |
| 79 | description: | 79 | description: |
| 80 | name: pedantic | 80 | name: pedantic |
| 81 | - url: "https://pub.dartlang.org" | 81 | + url: "https://pub.flutter-io.cn" |
| 82 | source: hosted | 82 | source: hosted |
| 83 | - version: "1.5.0" | 83 | + version: "1.7.0" |
| 84 | quiver: | 84 | quiver: |
| 85 | dependency: transitive | 85 | dependency: transitive |
| 86 | description: | 86 | description: |
| 87 | name: quiver | 87 | name: quiver |
| 88 | - url: "https://pub.dartlang.org" | 88 | + url: "https://pub.flutter-io.cn" |
| 89 | source: hosted | 89 | source: hosted |
| 90 | - version: "2.0.2" | 90 | + version: "2.0.3" |
| 91 | sky_engine: | 91 | sky_engine: |
| 92 | dependency: transitive | 92 | dependency: transitive |
| 93 | description: flutter | 93 | description: flutter |
| @@ -97,57 +97,57 @@ packages: | @@ -97,57 +97,57 @@ packages: | ||
| 97 | dependency: transitive | 97 | dependency: transitive |
| 98 | description: | 98 | description: |
| 99 | name: source_span | 99 | name: source_span |
| 100 | - url: "https://pub.dartlang.org" | 100 | + url: "https://pub.flutter-io.cn" |
| 101 | source: hosted | 101 | source: hosted |
| 102 | version: "1.5.5" | 102 | version: "1.5.5" |
| 103 | stack_trace: | 103 | stack_trace: |
| 104 | dependency: transitive | 104 | dependency: transitive |
| 105 | description: | 105 | description: |
| 106 | name: stack_trace | 106 | name: stack_trace |
| 107 | - url: "https://pub.dartlang.org" | 107 | + url: "https://pub.flutter-io.cn" |
| 108 | source: hosted | 108 | source: hosted |
| 109 | version: "1.9.3" | 109 | version: "1.9.3" |
| 110 | stream_channel: | 110 | stream_channel: |
| 111 | dependency: transitive | 111 | dependency: transitive |
| 112 | description: | 112 | description: |
| 113 | name: stream_channel | 113 | name: stream_channel |
| 114 | - url: "https://pub.dartlang.org" | 114 | + url: "https://pub.flutter-io.cn" |
| 115 | source: hosted | 115 | source: hosted |
| 116 | version: "2.0.0" | 116 | version: "2.0.0" |
| 117 | string_scanner: | 117 | string_scanner: |
| 118 | dependency: transitive | 118 | dependency: transitive |
| 119 | description: | 119 | description: |
| 120 | name: string_scanner | 120 | name: string_scanner |
| 121 | - url: "https://pub.dartlang.org" | 121 | + url: "https://pub.flutter-io.cn" |
| 122 | source: hosted | 122 | source: hosted |
| 123 | version: "1.0.4" | 123 | version: "1.0.4" |
| 124 | term_glyph: | 124 | term_glyph: |
| 125 | dependency: transitive | 125 | dependency: transitive |
| 126 | description: | 126 | description: |
| 127 | name: term_glyph | 127 | name: term_glyph |
| 128 | - url: "https://pub.dartlang.org" | 128 | + url: "https://pub.flutter-io.cn" |
| 129 | source: hosted | 129 | source: hosted |
| 130 | version: "1.1.0" | 130 | version: "1.1.0" |
| 131 | test_api: | 131 | test_api: |
| 132 | dependency: transitive | 132 | dependency: transitive |
| 133 | description: | 133 | description: |
| 134 | name: test_api | 134 | name: test_api |
| 135 | - url: "https://pub.dartlang.org" | 135 | + url: "https://pub.flutter-io.cn" |
| 136 | source: hosted | 136 | source: hosted |
| 137 | - version: "0.2.4" | 137 | + version: "0.2.5" |
| 138 | typed_data: | 138 | typed_data: |
| 139 | dependency: transitive | 139 | dependency: transitive |
| 140 | description: | 140 | description: |
| 141 | name: typed_data | 141 | name: typed_data |
| 142 | - url: "https://pub.dartlang.org" | 142 | + url: "https://pub.flutter-io.cn" |
| 143 | source: hosted | 143 | source: hosted |
| 144 | version: "1.1.6" | 144 | version: "1.1.6" |
| 145 | vector_math: | 145 | vector_math: |
| 146 | dependency: transitive | 146 | dependency: transitive |
| 147 | description: | 147 | description: |
| 148 | name: vector_math | 148 | name: vector_math |
| 149 | - url: "https://pub.dartlang.org" | 149 | + url: "https://pub.flutter-io.cn" |
| 150 | source: hosted | 150 | source: hosted |
| 151 | version: "2.0.8" | 151 | version: "2.0.8" |
| 152 | sdks: | 152 | sdks: |
| 153 | - dart: ">=2.2.0 <3.0.0" | 153 | + dart: ">=2.2.2 <3.0.0" |
| @@ -8,9 +8,13 @@ import 'package:flutter/material.dart'; | @@ -8,9 +8,13 @@ import 'package:flutter/material.dart'; | ||
| 8 | class ScreenUtil { | 8 | class ScreenUtil { |
| 9 | static ScreenUtil instance = new ScreenUtil(); | 9 | static ScreenUtil instance = new ScreenUtil(); |
| 10 | 10 | ||
| 11 | - //设计稿的设备尺寸修改 | 11 | + /// UI设计中手机尺寸 , px |
| 12 | + /// Size of the phone in UI Design , px | ||
| 12 | double width; | 13 | double width; |
| 13 | double height; | 14 | double height; |
| 15 | + | ||
| 16 | + /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 | ||
| 17 | + /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. | ||
| 14 | bool allowFontScaling; | 18 | bool allowFontScaling; |
| 15 | 19 | ||
| 16 | static MediaQueryData _mediaQueryData; | 20 | static MediaQueryData _mediaQueryData; |
| @@ -46,49 +50,66 @@ class ScreenUtil { | @@ -46,49 +50,66 @@ class ScreenUtil { | ||
| 46 | 50 | ||
| 47 | static MediaQueryData get mediaQueryData => _mediaQueryData; | 51 | static MediaQueryData get mediaQueryData => _mediaQueryData; |
| 48 | 52 | ||
| 49 | - ///每个逻辑像素的字体像素数,字体的缩放比例 | 53 | + /// 每个逻辑像素的字体像素数,字体的缩放比例 |
| 54 | + /// The number of font pixels for each logical pixel. | ||
| 50 | static double get textScaleFactory => _textScaleFactor; | 55 | static double get textScaleFactory => _textScaleFactor; |
| 51 | 56 | ||
| 52 | - ///设备的像素密度 | 57 | + /// 设备的像素密度 |
| 58 | + /// The size of the media in logical pixels (e.g, the size of the screen). | ||
| 53 | static double get pixelRatio => _pixelRatio; | 59 | static double get pixelRatio => _pixelRatio; |
| 54 | 60 | ||
| 55 | - ///当前设备宽度 dp | 61 | + /// 当前设备宽度 dp |
| 62 | + /// The horizontal extent of this size. | ||
| 56 | static double get screenWidthDp => _screenWidth; | 63 | static double get screenWidthDp => _screenWidth; |
| 57 | 64 | ||
| 58 | ///当前设备高度 dp | 65 | ///当前设备高度 dp |
| 66 | + ///The vertical extent of this size. dp | ||
| 59 | static double get screenHeightDp => _screenHeight; | 67 | static double get screenHeightDp => _screenHeight; |
| 60 | 68 | ||
| 61 | - ///当前设备宽度 px | 69 | + /// 当前设备宽度 px |
| 70 | + /// The vertical extent of this size. px | ||
| 62 | static double get screenWidth => _screenWidth * _pixelRatio; | 71 | static double get screenWidth => _screenWidth * _pixelRatio; |
| 63 | 72 | ||
| 64 | - ///当前设备高度 px | 73 | + /// 当前设备高度 px |
| 74 | + /// The vertical extent of this size. px | ||
| 65 | static double get screenHeight => _screenHeight * _pixelRatio; | 75 | static double get screenHeight => _screenHeight * _pixelRatio; |
| 66 | 76 | ||
| 67 | - ///状态栏高度 dp 刘海屏会更高 | 77 | + /// 状态栏高度 dp 刘海屏会更高 |
| 78 | + /// The offset from the top | ||
| 68 | static double get statusBarHeight => _statusBarHeight; | 79 | static double get statusBarHeight => _statusBarHeight; |
| 69 | 80 | ||
| 70 | - ///底部安全区距离 dp | 81 | + /// 底部安全区距离 dp |
| 82 | + /// The offset from the bottom. | ||
| 71 | static double get bottomBarHeight => _bottomBarHeight; | 83 | static double get bottomBarHeight => _bottomBarHeight; |
| 72 | 84 | ||
| 73 | - ///实际的dp与设计稿px的比例 | 85 | + /// 实际的dp与UI设计px的比例 |
| 86 | + /// The ratio of the actual dp to the design draft px | ||
| 74 | get scaleWidth => _screenWidth / instance.width; | 87 | get scaleWidth => _screenWidth / instance.width; |
| 75 | 88 | ||
| 76 | get scaleHeight => _screenHeight / instance.height; | 89 | get scaleHeight => _screenHeight / instance.height; |
| 77 | 90 | ||
| 78 | - ///根据设计稿的设备宽度适配 | ||
| 79 | - ///高度也根据这个来做适配可以保证不变形 | 91 | + /// 根据UI设计的设备宽度适配 |
| 92 | + /// 高度也可以根据这个来做适配可以保证不变形,比如你先要一个正方形的时候. | ||
| 93 | + /// Adapted to the device width of the UI Design. | ||
| 94 | + /// Height can also be adapted according to this to ensure no deformation , | ||
| 95 | + /// if you want a square | ||
| 80 | setWidth(double width) => width * scaleWidth; | 96 | setWidth(double width) => width * scaleWidth; |
| 81 | 97 | ||
| 82 | - /// 根据设计稿的设备高度适配 | ||
| 83 | - /// 当发现设计稿中的一屏显示的与当前样式效果不符合时, | ||
| 84 | - /// 或者形状有差异时,高度适配建议使用此方法 | ||
| 85 | - /// 高度适配主要针对想根据设计稿的一屏展示一样的效果 | 98 | + /// 根据UI设计的设备高度适配 |
| 99 | + /// 当发现UI设计中的一屏显示的与当前样式效果不符合时, | ||
| 100 | + /// 或者形状有差异时,建议使用此方法实现高度适配. | ||
| 101 | + /// 高度适配主要针对想根据UI设计的一屏展示一样的效果 | ||
| 102 | + /// Highly adaptable to the device according to UI Design | ||
| 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 | ||
| 105 | + /// does not match the current style effect, or if there is a difference in shape. | ||
| 86 | setHeight(double height) => height * scaleHeight; | 106 | setHeight(double height) => height * scaleHeight; |
| 87 | 107 | ||
| 88 | ///字体大小适配方法 | 108 | ///字体大小适配方法 |
| 89 | - ///@param fontSize 传入设计稿上字体的px , | ||
| 90 | - ///@param allowFontScaling 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 | ||
| 91 | - ///@param allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. | 109 | + ///@param [fontSize] UI设计上字体的大小,单位px. |
| 110 | + ///Font size adaptation method | ||
| 111 | + ///@param [fontSize] The size of the font on the UI design, in px. | ||
| 112 | + ///@param [allowFontScaling] | ||
| 92 | setSp(double fontSize) => allowFontScaling | 113 | setSp(double fontSize) => allowFontScaling |
| 93 | ? setWidth(fontSize) | 114 | ? setWidth(fontSize) |
| 94 | : setWidth(fontSize) / _textScaleFactor; | 115 | : setWidth(fontSize) / _textScaleFactor; |
| 1 | # Generated by pub | 1 | # Generated by pub |
| 2 | -# See https://www.dartlang.org/tools/pub/glossary#lockfile | 2 | +# See https://dart.dev/tools/pub/glossary#lockfile |
| 3 | packages: | 3 | packages: |
| 4 | async: | 4 | async: |
| 5 | dependency: transitive | 5 | dependency: transitive |
| 6 | description: | 6 | description: |
| 7 | name: async | 7 | name: async |
| 8 | - url: "https://pub.dartlang.org" | 8 | + url: "https://pub.flutter-io.cn" |
| 9 | source: hosted | 9 | source: hosted |
| 10 | - version: "2.1.0" | 10 | + version: "2.2.0" |
| 11 | boolean_selector: | 11 | boolean_selector: |
| 12 | dependency: transitive | 12 | dependency: transitive |
| 13 | description: | 13 | description: |
| 14 | name: boolean_selector | 14 | name: boolean_selector |
| 15 | - url: "https://pub.dartlang.org" | 15 | + url: "https://pub.flutter-io.cn" |
| 16 | source: hosted | 16 | source: hosted |
| 17 | version: "1.0.4" | 17 | version: "1.0.4" |
| 18 | charcode: | 18 | charcode: |
| 19 | dependency: transitive | 19 | dependency: transitive |
| 20 | description: | 20 | description: |
| 21 | name: charcode | 21 | name: charcode |
| 22 | - url: "https://pub.dartlang.org" | 22 | + url: "https://pub.flutter-io.cn" |
| 23 | source: hosted | 23 | source: hosted |
| 24 | version: "1.1.2" | 24 | version: "1.1.2" |
| 25 | collection: | 25 | collection: |
| 26 | dependency: transitive | 26 | dependency: transitive |
| 27 | description: | 27 | description: |
| 28 | name: collection | 28 | name: collection |
| 29 | - url: "https://pub.dartlang.org" | 29 | + url: "https://pub.flutter-io.cn" |
| 30 | source: hosted | 30 | source: hosted |
| 31 | version: "1.14.11" | 31 | version: "1.14.11" |
| 32 | flutter: | 32 | flutter: |
| @@ -43,37 +43,37 @@ packages: | @@ -43,37 +43,37 @@ packages: | ||
| 43 | dependency: transitive | 43 | dependency: transitive |
| 44 | description: | 44 | description: |
| 45 | name: matcher | 45 | name: matcher |
| 46 | - url: "https://pub.dartlang.org" | 46 | + url: "https://pub.flutter-io.cn" |
| 47 | source: hosted | 47 | source: hosted |
| 48 | version: "0.12.5" | 48 | version: "0.12.5" |
| 49 | meta: | 49 | meta: |
| 50 | dependency: transitive | 50 | dependency: transitive |
| 51 | description: | 51 | description: |
| 52 | name: meta | 52 | name: meta |
| 53 | - url: "https://pub.dartlang.org" | 53 | + url: "https://pub.flutter-io.cn" |
| 54 | source: hosted | 54 | source: hosted |
| 55 | version: "1.1.6" | 55 | version: "1.1.6" |
| 56 | path: | 56 | path: |
| 57 | dependency: transitive | 57 | dependency: transitive |
| 58 | description: | 58 | description: |
| 59 | name: path | 59 | name: path |
| 60 | - url: "https://pub.dartlang.org" | 60 | + url: "https://pub.flutter-io.cn" |
| 61 | source: hosted | 61 | source: hosted |
| 62 | version: "1.6.2" | 62 | version: "1.6.2" |
| 63 | pedantic: | 63 | pedantic: |
| 64 | dependency: transitive | 64 | dependency: transitive |
| 65 | description: | 65 | description: |
| 66 | name: pedantic | 66 | name: pedantic |
| 67 | - url: "https://pub.dartlang.org" | 67 | + url: "https://pub.flutter-io.cn" |
| 68 | source: hosted | 68 | source: hosted |
| 69 | - version: "1.5.0" | 69 | + version: "1.7.0" |
| 70 | quiver: | 70 | quiver: |
| 71 | dependency: transitive | 71 | dependency: transitive |
| 72 | description: | 72 | description: |
| 73 | name: quiver | 73 | name: quiver |
| 74 | - url: "https://pub.dartlang.org" | 74 | + url: "https://pub.flutter-io.cn" |
| 75 | source: hosted | 75 | source: hosted |
| 76 | - version: "2.0.2" | 76 | + version: "2.0.3" |
| 77 | sky_engine: | 77 | sky_engine: |
| 78 | dependency: transitive | 78 | dependency: transitive |
| 79 | description: flutter | 79 | description: flutter |
| @@ -83,57 +83,57 @@ packages: | @@ -83,57 +83,57 @@ packages: | ||
| 83 | dependency: transitive | 83 | dependency: transitive |
| 84 | description: | 84 | description: |
| 85 | name: source_span | 85 | name: source_span |
| 86 | - url: "https://pub.dartlang.org" | 86 | + url: "https://pub.flutter-io.cn" |
| 87 | source: hosted | 87 | source: hosted |
| 88 | version: "1.5.5" | 88 | version: "1.5.5" |
| 89 | stack_trace: | 89 | stack_trace: |
| 90 | dependency: transitive | 90 | dependency: transitive |
| 91 | description: | 91 | description: |
| 92 | name: stack_trace | 92 | name: stack_trace |
| 93 | - url: "https://pub.dartlang.org" | 93 | + url: "https://pub.flutter-io.cn" |
| 94 | source: hosted | 94 | source: hosted |
| 95 | version: "1.9.3" | 95 | version: "1.9.3" |
| 96 | stream_channel: | 96 | stream_channel: |
| 97 | dependency: transitive | 97 | dependency: transitive |
| 98 | description: | 98 | description: |
| 99 | name: stream_channel | 99 | name: stream_channel |
| 100 | - url: "https://pub.dartlang.org" | 100 | + url: "https://pub.flutter-io.cn" |
| 101 | source: hosted | 101 | source: hosted |
| 102 | version: "2.0.0" | 102 | version: "2.0.0" |
| 103 | string_scanner: | 103 | string_scanner: |
| 104 | dependency: transitive | 104 | dependency: transitive |
| 105 | description: | 105 | description: |
| 106 | name: string_scanner | 106 | name: string_scanner |
| 107 | - url: "https://pub.dartlang.org" | 107 | + url: "https://pub.flutter-io.cn" |
| 108 | source: hosted | 108 | source: hosted |
| 109 | version: "1.0.4" | 109 | version: "1.0.4" |
| 110 | term_glyph: | 110 | term_glyph: |
| 111 | dependency: transitive | 111 | dependency: transitive |
| 112 | description: | 112 | description: |
| 113 | name: term_glyph | 113 | name: term_glyph |
| 114 | - url: "https://pub.dartlang.org" | 114 | + url: "https://pub.flutter-io.cn" |
| 115 | source: hosted | 115 | source: hosted |
| 116 | version: "1.1.0" | 116 | version: "1.1.0" |
| 117 | test_api: | 117 | test_api: |
| 118 | dependency: transitive | 118 | dependency: transitive |
| 119 | description: | 119 | description: |
| 120 | name: test_api | 120 | name: test_api |
| 121 | - url: "https://pub.dartlang.org" | 121 | + url: "https://pub.flutter-io.cn" |
| 122 | source: hosted | 122 | source: hosted |
| 123 | - version: "0.2.4" | 123 | + version: "0.2.5" |
| 124 | typed_data: | 124 | typed_data: |
| 125 | dependency: transitive | 125 | dependency: transitive |
| 126 | description: | 126 | description: |
| 127 | name: typed_data | 127 | name: typed_data |
| 128 | - url: "https://pub.dartlang.org" | 128 | + url: "https://pub.flutter-io.cn" |
| 129 | source: hosted | 129 | source: hosted |
| 130 | version: "1.1.6" | 130 | version: "1.1.6" |
| 131 | vector_math: | 131 | vector_math: |
| 132 | dependency: transitive | 132 | dependency: transitive |
| 133 | description: | 133 | description: |
| 134 | name: vector_math | 134 | name: vector_math |
| 135 | - url: "https://pub.dartlang.org" | 135 | + url: "https://pub.flutter-io.cn" |
| 136 | source: hosted | 136 | source: hosted |
| 137 | version: "2.0.8" | 137 | version: "2.0.8" |
| 138 | sdks: | 138 | sdks: |
| 139 | - dart: ">=2.2.0 <3.0.0" | 139 | + dart: ">=2.2.2 <3.0.0" |
| 1 | name: flutter_screenutil | 1 | name: flutter_screenutil |
| 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models | 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models |
| 3 | -version: 0.5.3 | 3 | +version: 0.6.0 |
| 4 | author: LiZhuoyuan <zhuoyuan93@gmail.com> | 4 | author: LiZhuoyuan <zhuoyuan93@gmail.com> |
| 5 | homepage: https://github.com/OpenFlutter/flutter_ScreenUtil | 5 | homepage: https://github.com/OpenFlutter/flutter_ScreenUtil |
| 6 | 6 |
-
Please register or login to post a comment