Showing
8 changed files
with
61 additions
and
51 deletions
1 | -# Generated by pub on 2018-10-17 15:16:22.083978. | 1 | +# Generated by pub on 2018-10-17 16:39:18.833879. |
2 | analyzer:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.32.4/lib/ | 2 | analyzer:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.32.4/lib/ |
3 | args:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-1.5.0/lib/ | 3 | args:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-1.5.0/lib/ |
4 | async:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.0.8/lib/ | 4 | async:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.0.8/lib/ |
@@ -9,3 +9,6 @@ | @@ -9,3 +9,6 @@ | ||
9 | ## [0.3.0] - Perfect documentation | 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 | 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 | 11 | Height is enlarged relative to the design draft => The ratio of height width to the size of the design |
12 | + | ||
13 | +## [0.4.0] - Optimize font adaptation method | ||
14 | + |
@@ -16,7 +16,7 @@ dependencies: | @@ -16,7 +16,7 @@ dependencies: | ||
16 | flutter: | 16 | flutter: |
17 | sdk: flutter | 17 | sdk: flutter |
18 | # add flutter_ScreenUtil | 18 | # add flutter_ScreenUtil |
19 | - flutter_screenutil: ^0.3.1 | 19 | + flutter_screenutil: ^0.4.0 |
20 | ``` | 20 | ``` |
21 | 21 | ||
22 | ### Add the following imports to your Dart code: | 22 | ### Add the following imports to your Dart code: |
@@ -76,8 +76,8 @@ Other related apis: | @@ -76,8 +76,8 @@ Other related apis: | ||
76 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px | 76 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px |
77 | ScreenUtil.textScaleFactory //System font scaling factor | 77 | ScreenUtil.textScaleFactory //System font scaling factor |
78 | 78 | ||
79 | - ScreenUtil().scaleWidth //The ratio of font and width to the size of the design | ||
80 | - ScreenUtil().scaleHeight //The ratio of height width to the size of the design | 79 | + ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px |
80 | + ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px | ||
81 | 81 | ||
82 | ``` | 82 | ``` |
83 | 83 | ||
@@ -100,9 +100,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -100,9 +100,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
100 | print( | 100 | print( |
101 | 'Status bar height:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | 101 | 'Status bar height:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px |
102 | print( | 102 | print( |
103 | - 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth}'); //The width is enlarged relative to the design draft | 103 | + 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); //The width is enlarged relative to the design draft |
104 | print( | 104 | print( |
105 | - 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight}'); //The height is enlarged relative to the design draft | 105 | + 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); //The height is enlarged relative to the design draft |
106 | 106 | ||
107 | return new Scaffold( | 107 | return new Scaffold( |
108 | appBar: new AppBar( | 108 | appBar: new AppBar( |
@@ -122,7 +122,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -122,7 +122,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
122 | 'My width:${ScreenUtil().setWidth(375)}dp', | 122 | 'My width:${ScreenUtil().setWidth(375)}dp', |
123 | style: TextStyle( | 123 | style: TextStyle( |
124 | color: Colors.white, | 124 | color: Colors.white, |
125 | - fontSize: ScreenUtil().setSp(28, false)), | 125 | + fontSize: ScreenUtil().setSp(12, false)), |
126 | ), | 126 | ), |
127 | ), | 127 | ), |
128 | Container( | 128 | Container( |
@@ -132,7 +132,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -132,7 +132,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
132 | child: Text('My width:${ScreenUtil().setWidth(375)}dp', | 132 | child: Text('My width:${ScreenUtil().setWidth(375)}dp', |
133 | style: TextStyle( | 133 | style: TextStyle( |
134 | color: Colors.white, | 134 | color: Colors.white, |
135 | - fontSize: ScreenUtil().setSp(28, false))), | 135 | + fontSize: ScreenUtil().setSp(12, false))), |
136 | ), | 136 | ), |
137 | ], | 137 | ], |
138 | ), | 138 | ), |
@@ -142,11 +142,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -142,11 +142,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
142 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'), | 142 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'), |
143 | Text('Status bar height:${ScreenUtil.statusBarHeight}px'), | 143 | Text('Status bar height:${ScreenUtil.statusBarHeight}px'), |
144 | Text( | 144 | Text( |
145 | - 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth}', | 145 | + 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', |
146 | textAlign: TextAlign.center, | 146 | textAlign: TextAlign.center, |
147 | ), | 147 | ), |
148 | Text( | 148 | Text( |
149 | - 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight}', | 149 | + 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', |
150 | textAlign: TextAlign.center, | 150 | textAlign: TextAlign.center, |
151 | ), | 151 | ), |
152 | SizedBox( | 152 | SizedBox( |
@@ -157,13 +157,17 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -157,13 +157,17 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
157 | crossAxisAlignment: CrossAxisAlignment.start, | 157 | crossAxisAlignment: CrossAxisAlignment.start, |
158 | children: <Widget>[ | 158 | children: <Widget>[ |
159 | Text( | 159 | Text( |
160 | - 'My font size is 28px and will not change with the system.', | 160 | + 'My font size is 14px on the design draft and will not change with the system.', |
161 | style: TextStyle( | 161 | style: TextStyle( |
162 | - color: Colors.black, | ||
163 | - fontSize: ScreenUtil().setSp(28, false))), | ||
164 | - Text('My font size is 28px and will change with the system.', | 162 | + color: Colors.black, |
163 | + fontSize: ScreenUtil().setSp(14, false), | ||
164 | + )), | ||
165 | + Text( | ||
166 | + 'My font size is 14px on the design draft and will change with the system.', | ||
165 | style: TextStyle( | 167 | style: TextStyle( |
166 | - color: Colors.black, fontSize: ScreenUtil().setSp(28))), | 168 | + color: Colors.black, |
169 | + fontSize: ScreenUtil().setSp(14), | ||
170 | + )), | ||
167 | ], | 171 | ], |
168 | ) | 172 | ) |
169 | ], | 173 | ], |
@@ -19,7 +19,7 @@ dependencies: | @@ -19,7 +19,7 @@ dependencies: | ||
19 | flutter: | 19 | flutter: |
20 | sdk: flutter | 20 | sdk: flutter |
21 | # 添加依赖 | 21 | # 添加依赖 |
22 | - flutter_screenutil: ^0.3.1 | 22 | + flutter_screenutil: ^0.4.0 |
23 | ``` | 23 | ``` |
24 | 24 | ||
25 | ### 在每个使用的地方导入包: | 25 | ### 在每个使用的地方导入包: |
@@ -77,8 +77,8 @@ for example: | @@ -77,8 +77,8 @@ for example: | ||
77 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px | 77 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px |
78 | ScreenUtil.textScaleFactory //系统字体缩放比例 | 78 | ScreenUtil.textScaleFactory //系统字体缩放比例 |
79 | 79 | ||
80 | - ScreenUtil().scaleWidth //字体和宽度相对设计稿放大的比例 | ||
81 | - ScreenUtil().scaleHeight //高度相对于设计稿放大的比例 | 80 | + ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例 |
81 | + ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例 | ||
82 | 82 | ||
83 | ``` | 83 | ``` |
84 | 84 | ||
@@ -88,7 +88,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -88,7 +88,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
88 | 88 | ||
89 | ... | 89 | ... |
90 | 90 | ||
91 | -@override | 91 | + @override |
92 | Widget build(BuildContext context) { | 92 | Widget build(BuildContext context) { |
93 | //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) | 93 | //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) |
94 | ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 94 | ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); |
@@ -100,9 +100,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -100,9 +100,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
100 | print( | 100 | print( |
101 | '状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | 101 | '状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px |
102 | print( | 102 | print( |
103 | - '字体和宽度相对设计稿放大的比例:${ScreenUtil().scaleWidth}'); //The width is enlarged relative to the design draft | 103 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); //The width is enlarged relative to the design draft |
104 | print( | 104 | print( |
105 | - '高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}'); //The height is enlarged relative to the design draft | 105 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); //The height is enlarged relative to the design draft |
106 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); | 106 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); |
107 | 107 | ||
108 | return new Scaffold( | 108 | return new Scaffold( |
@@ -143,11 +143,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -143,11 +143,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
143 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'), | 143 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'), |
144 | Text('状态栏高度:${ScreenUtil.statusBarHeight}px'), | 144 | Text('状态栏高度:${ScreenUtil.statusBarHeight}px'), |
145 | Text( | 145 | Text( |
146 | - '字体和宽度相对设计稿放大的比例:${ScreenUtil().scaleWidth}', | 146 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', |
147 | textAlign: TextAlign.center, | 147 | textAlign: TextAlign.center, |
148 | ), | 148 | ), |
149 | Text( | 149 | Text( |
150 | - '高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}', | 150 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', |
151 | textAlign: TextAlign.center, | 151 | textAlign: TextAlign.center, |
152 | ), | 152 | ), |
153 | SizedBox( | 153 | SizedBox( |
@@ -157,13 +157,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -157,13 +157,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
157 | Column( | 157 | Column( |
158 | crossAxisAlignment: CrossAxisAlignment.start, | 158 | crossAxisAlignment: CrossAxisAlignment.start, |
159 | children: <Widget>[ | 159 | children: <Widget>[ |
160 | - Text('我的文字大小是28px,不会随着系统的文字大小变化', | 160 | + Text('我的文字大小是14px,不会随着系统的文字大小变化', |
161 | style: TextStyle( | 161 | style: TextStyle( |
162 | color: Colors.black, | 162 | color: Colors.black, |
163 | - fontSize: ScreenUtil().setSp(28, false))), | ||
164 | - Text('我的文字大小是28px,会随着系统的文字大小变化', | 163 | + fontSize: ScreenUtil().setSp(14, false))), |
164 | + Text('我的文字大小是14px,会随着系统的文字大小变化', | ||
165 | style: TextStyle( | 165 | style: TextStyle( |
166 | - color: Colors.black, fontSize: ScreenUtil().setSp(28))), | 166 | + color: Colors.black, fontSize: ScreenUtil().setSp(14))), |
167 | ], | 167 | ], |
168 | ) | 168 | ) |
169 | ], | 169 | ], |
@@ -41,10 +41,9 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -41,10 +41,9 @@ class _MyHomePageState extends State<MyHomePage> { | ||
41 | print( | 41 | print( |
42 | 'Status bar height:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | 42 | 'Status bar height:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px |
43 | print( | 43 | print( |
44 | - 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth}'); //The width is enlarged relative to the design draft | 44 | + 'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); //The width is enlarged relative to the design draft |
45 | print( | 45 | print( |
46 | - 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight}'); //The height is enlarged relative to the design draft | ||
47 | - | 46 | + 'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); //The height is enlarged relative to the design draft |
48 | return new Scaffold( | 47 | return new Scaffold( |
49 | appBar: new AppBar( | 48 | appBar: new AppBar( |
50 | title: new Text(widget.title), | 49 | title: new Text(widget.title), |
@@ -63,7 +62,7 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -63,7 +62,7 @@ class _MyHomePageState extends State<MyHomePage> { | ||
63 | 'My width:${ScreenUtil().setWidth(375)}dp', | 62 | 'My width:${ScreenUtil().setWidth(375)}dp', |
64 | style: TextStyle( | 63 | style: TextStyle( |
65 | color: Colors.white, | 64 | color: Colors.white, |
66 | - fontSize: ScreenUtil().setSp(28, false)), | 65 | + fontSize: ScreenUtil().setSp(12, false)), |
67 | ), | 66 | ), |
68 | ), | 67 | ), |
69 | Container( | 68 | Container( |
@@ -73,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -73,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> { | ||
73 | child: Text('My width:${ScreenUtil().setWidth(375)}dp', | 72 | child: Text('My width:${ScreenUtil().setWidth(375)}dp', |
74 | style: TextStyle( | 73 | style: TextStyle( |
75 | color: Colors.white, | 74 | color: Colors.white, |
76 | - fontSize: ScreenUtil().setSp(28, false))), | 75 | + fontSize: ScreenUtil().setSp(12, false))), |
77 | ), | 76 | ), |
78 | ], | 77 | ], |
79 | ), | 78 | ), |
@@ -83,11 +82,11 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -83,11 +82,11 @@ class _MyHomePageState extends State<MyHomePage> { | ||
83 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'), | 82 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'), |
84 | Text('Status bar height:${ScreenUtil.statusBarHeight}px'), | 83 | Text('Status bar height:${ScreenUtil.statusBarHeight}px'), |
85 | Text( | 84 | Text( |
86 | - 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth}', | 85 | + 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', |
87 | textAlign: TextAlign.center, | 86 | textAlign: TextAlign.center, |
88 | ), | 87 | ), |
89 | Text( | 88 | Text( |
90 | - 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight}', | 89 | + 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', |
91 | textAlign: TextAlign.center, | 90 | textAlign: TextAlign.center, |
92 | ), | 91 | ), |
93 | SizedBox( | 92 | SizedBox( |
@@ -98,13 +97,17 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -98,13 +97,17 @@ class _MyHomePageState extends State<MyHomePage> { | ||
98 | crossAxisAlignment: CrossAxisAlignment.start, | 97 | crossAxisAlignment: CrossAxisAlignment.start, |
99 | children: <Widget>[ | 98 | children: <Widget>[ |
100 | Text( | 99 | Text( |
101 | - 'My font size is 28px and will not change with the system.', | 100 | + 'My font size is 14px on the design draft and will not change with the system.', |
102 | style: TextStyle( | 101 | style: TextStyle( |
103 | - color: Colors.black, | ||
104 | - fontSize: ScreenUtil().setSp(28, false))), | ||
105 | - Text('My font size is 28px and will change with the system.', | 102 | + color: Colors.black, |
103 | + fontSize: ScreenUtil().setSp(14, false), | ||
104 | + )), | ||
105 | + Text( | ||
106 | + 'My font size is 14px on the design draft and will change with the system.', | ||
106 | style: TextStyle( | 107 | style: TextStyle( |
107 | - color: Colors.black, fontSize: ScreenUtil().setSp(28))), | 108 | + color: Colors.black, |
109 | + fontSize: ScreenUtil().setSp(14), | ||
110 | + )), | ||
108 | ], | 111 | ], |
109 | ) | 112 | ) |
110 | ], | 113 | ], |
@@ -40,9 +40,9 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -40,9 +40,9 @@ class _MyHomePageState extends State<MyHomePage> { | ||
40 | print( | 40 | print( |
41 | '状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | 41 | '状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px |
42 | print( | 42 | print( |
43 | - '字体和宽度相对设计稿放大的比例:${ScreenUtil().scaleWidth}'); //The width is enlarged relative to the design draft | 43 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); //The width is enlarged relative to the design draft |
44 | print( | 44 | print( |
45 | - '高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}'); //The height is enlarged relative to the design draft | 45 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); //The height is enlarged relative to the design draft |
46 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); | 46 | print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}'); |
47 | 47 | ||
48 | return new Scaffold( | 48 | return new Scaffold( |
@@ -83,11 +83,11 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -83,11 +83,11 @@ class _MyHomePageState extends State<MyHomePage> { | ||
83 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'), | 83 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'), |
84 | Text('状态栏高度:${ScreenUtil.statusBarHeight}px'), | 84 | Text('状态栏高度:${ScreenUtil.statusBarHeight}px'), |
85 | Text( | 85 | Text( |
86 | - '字体和宽度相对设计稿放大的比例:${ScreenUtil().scaleWidth}', | 86 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', |
87 | textAlign: TextAlign.center, | 87 | textAlign: TextAlign.center, |
88 | ), | 88 | ), |
89 | Text( | 89 | Text( |
90 | - '高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}', | 90 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', |
91 | textAlign: TextAlign.center, | 91 | textAlign: TextAlign.center, |
92 | ), | 92 | ), |
93 | SizedBox( | 93 | SizedBox( |
@@ -97,13 +97,13 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -97,13 +97,13 @@ class _MyHomePageState extends State<MyHomePage> { | ||
97 | Column( | 97 | Column( |
98 | crossAxisAlignment: CrossAxisAlignment.start, | 98 | crossAxisAlignment: CrossAxisAlignment.start, |
99 | children: <Widget>[ | 99 | children: <Widget>[ |
100 | - Text('我的文字大小是28px,不会随着系统的文字大小变化', | 100 | + Text('我的文字大小是14px,不会随着系统的文字大小变化', |
101 | style: TextStyle( | 101 | style: TextStyle( |
102 | color: Colors.black, | 102 | color: Colors.black, |
103 | - fontSize: ScreenUtil().setSp(28, false))), | ||
104 | - Text('我的文字大小是28px,会随着系统的文字大小变化', | 103 | + fontSize: ScreenUtil().setSp(14, false))), |
104 | + Text('我的文字大小是14px,会随着系统的文字大小变化', | ||
105 | style: TextStyle( | 105 | style: TextStyle( |
106 | - color: Colors.black, fontSize: ScreenUtil().setSp(28))), | 106 | + color: Colors.black, fontSize: ScreenUtil().setSp(14))), |
107 | ], | 107 | ], |
108 | ) | 108 | ) |
109 | ], | 109 | ], |
@@ -62,7 +62,7 @@ class ScreenUtil { | @@ -62,7 +62,7 @@ class ScreenUtil { | ||
62 | ///底部安全区距离 | 62 | ///底部安全区距离 |
63 | static double get bottomBarHeight => _bottomBarHeight * _pixelRatio; | 63 | static double get bottomBarHeight => _bottomBarHeight * _pixelRatio; |
64 | 64 | ||
65 | - ///相对于设计稿放大的倍数 | 65 | + ///实际的dp与设计稿px的比例 |
66 | get scaleWidth => _screenWidth / instance._designWidth; | 66 | get scaleWidth => _screenWidth / instance._designWidth; |
67 | 67 | ||
68 | get scaleHeight => _screenHeight / instance._designHeight; | 68 | get scaleHeight => _screenHeight / instance._designHeight; |
@@ -82,6 +82,6 @@ class ScreenUtil { | @@ -82,6 +82,6 @@ class ScreenUtil { | ||
82 | ///@param allowFontScaling 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为true。 | 82 | ///@param allowFontScaling 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为true。 |
83 | ///@param allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is true. | 83 | ///@param allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is true. |
84 | setSp(int fontSize, [allowFontScaling = true]) => allowFontScaling | 84 | setSp(int fontSize, [allowFontScaling = true]) => allowFontScaling |
85 | - ? setWidth(fontSize) * _textScaleFactor | ||
86 | - : setWidth(fontSize); | 85 | + ? setWidth(fontSize) * _pixelRatio * _textScaleFactor |
86 | + : setWidth(fontSize) * _pixelRatio; | ||
87 | } | 87 | } |
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.3.1 | 3 | +version: 0.4.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