Showing
18 changed files
with
652 additions
and
397 deletions
1 | -# Generated by pub on 2019-11-29 11:43:17.634960. | ||
2 | -async:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.3.0/lib/ | ||
3 | -boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.5/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/ | 1 | +# Generated by pub on 2020-01-06 16:51:35.863956. |
2 | +archive:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.11/lib/ | ||
3 | +args:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.2/lib/ | ||
4 | +async:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.0/lib/ | ||
5 | +boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.5/lib/ | ||
6 | +charcode:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/ | ||
7 | +collection:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/ | ||
8 | +convert:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/ | ||
9 | +crypto:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.3/lib/ | ||
6 | flutter:file:///D:/flutter/packages/flutter/lib/ | 10 | flutter:file:///D:/flutter/packages/flutter/lib/ |
7 | flutter_test:file:///D:/flutter/packages/flutter_test/lib/ | 11 | flutter_test:file:///D:/flutter/packages/flutter_test/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.7/lib/ | ||
10 | -path:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.4/lib/ | ||
11 | -pedantic:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/pedantic-1.8.0+1/lib/ | ||
12 | -quiver:file:///D:/flutter/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.5/lib/ | 12 | +image:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.4/lib/ |
13 | +matcher:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6/lib/ | ||
14 | +meta:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/ | ||
15 | +path:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/ | ||
16 | +pedantic:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.8.0+1/lib/ | ||
17 | +petitparser:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0/lib/ | ||
18 | +quiver:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.5/lib/ | ||
13 | sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/ | 19 | sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/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.5/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/ | 20 | +source_span:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/ |
21 | +stack_trace:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/ | ||
22 | +stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/ | ||
23 | +string_scanner:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/ | ||
24 | +term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/ | ||
25 | +test_api:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.11/lib/ | ||
26 | +typed_data:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/ | ||
27 | +vector_math:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/ | ||
28 | +xml:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/xml-3.5.0/lib/ | ||
22 | flutter_screenutil:lib/ | 29 | flutter_screenutil:lib/ |
@@ -2,10 +2,19 @@ | @@ -2,10 +2,19 @@ | ||
2 | * @Author: zhuoyuan93@gmail.com | 2 | * @Author: zhuoyuan93@gmail.com |
3 | * @Date: 2018-10-16 19:43:03 | 3 | * @Date: 2018-10-16 19:43:03 |
4 | * @LastEditors: zhuoyuan93@gmail.com | 4 | * @LastEditors: zhuoyuan93@gmail.com |
5 | - * @LastEditTime: 2019-11-29 11:42 | 5 | + * @LastEditTime: 2020年1月6日 16:41:02 |
6 | * @Description: Update log | 6 | * @Description: Update log |
7 | --> | 7 | --> |
8 | - | 8 | + |
9 | +#1.0.0 | ||
10 | +- Rebuild code, change API | ||
11 | +- Modify the initialization method | ||
12 | +- Fix #68 | ||
13 | +- CompileSdkVersion change to 28 | ||
14 | +- Change example code | ||
15 | + | ||
16 | +If there is significant impact, please return to 0.7.0 | ||
17 | + | ||
9 | #0.7.0 | 18 | #0.7.0 |
10 | 19 | ||
11 | - Replace textScaleFactory with textScaleFactor , It's a typo. | 20 | - Replace textScaleFactory with textScaleFactor , It's a typo. |
@@ -23,7 +23,7 @@ dependencies: | @@ -23,7 +23,7 @@ dependencies: | ||
23 | flutter: | 23 | flutter: |
24 | sdk: flutter | 24 | sdk: flutter |
25 | # add flutter_screenutil | 25 | # add flutter_screenutil |
26 | - flutter_screenutil: ^0.7.0 | 26 | + flutter_screenutil: ^1.0.0 |
27 | ``` | 27 | ``` |
28 | 28 | ||
29 | ### Add the following imports to your Dart code: | 29 | ### Add the following imports to your Dart code: |
@@ -48,13 +48,13 @@ Be sure to set the page in the MaterialApp's home(ie the entry file, just set it | @@ -48,13 +48,13 @@ Be sure to set the page in the MaterialApp's home(ie the entry file, just set it | ||
48 | //fill in the screen size of the device in the design | 48 | //fill in the screen size of the device in the design |
49 | 49 | ||
50 | //default value : width : 1080px , height:1920px , allowFontScaling:false | 50 | //default value : width : 1080px , height:1920px , allowFontScaling:false |
51 | -ScreenUtil.instance = ScreenUtil.getInstance()..init(context); | 51 | +ScreenUtil.init(context); |
52 | 52 | ||
53 | //If the design is based on the size of the iPhone6 (iPhone6 750*1334) | 53 | //If the design is based on the size of the iPhone6 (iPhone6 750*1334) |
54 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 54 | +ScreenUtil.init(context, width: 750, height: 1334); |
55 | 55 | ||
56 | //If you want to set the font size is scaled according to the system's "font size" assist option | 56 | //If you want to set the font size is scaled according to the system's "font size" assist option |
57 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context); | 57 | +ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); |
58 | 58 | ||
59 | ``` | 59 | ``` |
60 | 60 | ||
@@ -64,12 +64,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | @@ -64,12 +64,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | ||
64 | 64 | ||
65 | Pass the px size of the design draft: | 65 | Pass the px size of the design draft: |
66 | 66 | ||
67 | -Adapted to screen width: `ScreenUtil.getInstance().setWidth(540)`, | 67 | +Adapted to screen width: `ScreenUtil().setWidth(540)`, |
68 | 68 | ||
69 | -Adapted to screen height: `ScreenUtil.getInstance().setHeight(200)`, | ||
70 | - | ||
71 | -You can also use `ScreenUtil()` instead of `ScreenUtil.getInstance()`, | ||
72 | -for example:`ScreenUtil().setHeight(200)` | 69 | +Adapted to screen height: `ScreenUtil().setHeight(200)`, |
73 | 70 | ||
74 | **Note** | 71 | **Note** |
75 | 72 | ||
@@ -81,15 +78,15 @@ setHeight method is mainly adapted in height, you want to control the height and | @@ -81,15 +78,15 @@ setHeight method is mainly adapted in height, you want to control the height and | ||
81 | //for example: | 78 | //for example: |
82 | //rectangle | 79 | //rectangle |
83 | Container( | 80 | Container( |
84 | - width: ScreenUtil.getInstance().setWidth(375), | ||
85 | - height: ScreenUtil.getInstance().setHeight(200), | 81 | + width: ScreenUtil().setWidth(375), |
82 | + height: ScreenUtil().setHeight(200), | ||
86 | ... | 83 | ... |
87 | ), | 84 | ), |
88 | 85 | ||
89 | ////If you want to display a square: | 86 | ////If you want to display a square: |
90 | Container( | 87 | Container( |
91 | - width: ScreenUtil.getInstance().setWidth(300), | ||
92 | - height: ScreenUtil.getInstance().setWidth(300), | 88 | + width: ScreenUtil().setWidth(300), |
89 | + height: ScreenUtil().setWidth(300), | ||
93 | ), | 90 | ), |
94 | 91 | ||
95 | ``` | 92 | ``` |
@@ -98,11 +95,11 @@ Container( | @@ -98,11 +95,11 @@ Container( | ||
98 | ``` dart | 95 | ``` dart |
99 | //Incoming font size,the unit is pixel, fonts will not scale to respect Text Size accessibility settings | 96 | //Incoming font size,the unit is pixel, fonts will not scale to respect Text Size accessibility settings |
100 | //(AllowallowFontScaling when initializing ScreenUtil) | 97 | //(AllowallowFontScaling when initializing ScreenUtil) |
101 | -ScreenUtil.getInstance().setSp(28) | 98 | +ScreenUtil().setSp(28) |
102 | 99 | ||
103 | //Incoming font size,the unit is pixel,fonts will scale to respect Text Size accessibility settings | 100 | //Incoming font size,the unit is pixel,fonts will scale to respect Text Size accessibility settings |
104 | //(If somewhere does not follow the global allowFontScaling setting) | 101 | //(If somewhere does not follow the global allowFontScaling setting) |
105 | -ScreenUtil(allowFontScaling: true).setSp(28) | 102 | +ScreenUtil().setSp(24, allowFontScalingSelf: true) |
106 | 103 | ||
107 | //for example: | 104 | //for example: |
108 | 105 | ||
@@ -113,18 +110,16 @@ Column( | @@ -113,18 +110,16 @@ Column( | ||
113 | 'My font size is 24px on the design draft and will not change with the system.', | 110 | 'My font size is 24px on the design draft and will not change with the system.', |
114 | style: TextStyle( | 111 | style: TextStyle( |
115 | color: Colors.black, | 112 | color: Colors.black, |
116 | - fontSize: ScreenUtil.getInstance().setSp(24), | 113 | + fontSize: ScreenUtil().setSp(24), |
117 | )), | 114 | )), |
118 | Text( | 115 | Text( |
119 | 'My font size is 24px on the design draft and will change with the system.', | 116 | 'My font size is 24px on the design draft and will change with the system.', |
120 | style: TextStyle( | 117 | style: TextStyle( |
121 | - color: Colors.black, | ||
122 | - fontSize: ScreenUtil(allowFontScaling: true).setSp(24), | ||
123 | - )), | 118 | + color: Colors.black, |
119 | + fontSize: ScreenUtil() | ||
120 | + .setSp(24, allowFontScalingSelf: true))), | ||
124 | ], | 121 | ], |
125 | ) | 122 | ) |
126 | - | ||
127 | - | ||
128 | ``` | 123 | ``` |
129 | 124 | ||
130 | #### Other related apis: | 125 | #### Other related apis: |
@@ -136,39 +131,60 @@ Column( | @@ -136,39 +131,60 @@ Column( | ||
136 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px | 131 | ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px |
137 | ScreenUtil.textScaleFactor //System font scaling factor | 132 | ScreenUtil.textScaleFactor //System font scaling factor |
138 | 133 | ||
139 | - ScreenUtil.getInstance().scaleWidth //Ratio of actual width dp to design draft px | ||
140 | - ScreenUtil.getInstance().scaleHeight //Ratio of actual height dp to design draft px | 134 | + ScreenUtil().scaleWidth //Ratio of actual width dp to design draft px |
135 | + ScreenUtil().scaleHeight //Ratio of actual height dp to design draft px | ||
141 | 136 | ||
142 | ``` | 137 | ``` |
143 | 138 | ||
144 | ```dart | 139 | ```dart |
145 | //import | 140 | //import |
141 | +import 'package:flutter/material.dart'; | ||
146 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 142 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
147 | 143 | ||
148 | -... | 144 | +void main() => runApp(new MyApp()); |
149 | 145 | ||
146 | +class MyApp extends StatelessWidget { | ||
150 | @override | 147 | @override |
151 | Widget build(BuildContext context) { | 148 | Widget build(BuildContext context) { |
152 | - ///Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334) | ||
153 | - ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | ||
154 | - | ||
155 | - print('Device width:${ScreenUtil.screenWidth}'); //Device width | ||
156 | - print('Device height:${ScreenUtil.screenHeight}'); //Device height | ||
157 | - print( | ||
158 | - 'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
159 | - print( | ||
160 | - 'Bottom safe zone distance:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | ||
161 | - print( | ||
162 | - 'Status bar height:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | ||
163 | - print( | ||
164 | - 'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}'); | ||
165 | - print( | ||
166 | - 'Ratio of actual height dp to design draft px:${ScreenUtil.getInstance().scaleHeight}'); | ||
167 | - print( | ||
168 | - 'The ratio of font and width to the size of the design:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}'); | ||
169 | - print( | ||
170 | - 'The ratio of height width to the size of the design:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | ||
171 | - | 149 | + return new MaterialApp( |
150 | + debugShowCheckedModeBanner: false, | ||
151 | + title: 'Flutter_ScreenUtil', | ||
152 | + theme: new ThemeData( | ||
153 | + primarySwatch: Colors.blue, | ||
154 | + ), | ||
155 | + home: new MyHomePage(), | ||
156 | + ); | ||
157 | + } | ||
158 | +} | ||
159 | + | ||
160 | +class MyHomePage extends StatefulWidget { | ||
161 | + @override | ||
162 | + _MyHomePageState createState() => new _MyHomePageState(); | ||
163 | +} | ||
164 | + | ||
165 | +class _MyHomePageState extends State<MyHomePage> { | ||
166 | + @override | ||
167 | + Widget build(BuildContext context) { | ||
168 | + //Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334) | ||
169 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
170 | + | ||
171 | + return ExampleWidget(title: 'FlutterScreenUtil Demo'); | ||
172 | + } | ||
173 | +} | ||
174 | + | ||
175 | +class ExampleWidget extends StatefulWidget { | ||
176 | + const ExampleWidget({Key key, this.title}) : super(key: key); | ||
177 | + | ||
178 | + final String title; | ||
179 | + | ||
180 | + @override | ||
181 | + _ExampleWidgetState createState() => _ExampleWidgetState(); | ||
182 | +} | ||
183 | + | ||
184 | +class _ExampleWidgetState extends State<ExampleWidget> { | ||
185 | + @override | ||
186 | + Widget build(BuildContext context) { | ||
187 | + printScreenInformation(); | ||
172 | return new Scaffold( | 188 | return new Scaffold( |
173 | appBar: new AppBar( | 189 | appBar: new AppBar( |
174 | title: new Text(widget.title), | 190 | title: new Text(widget.title), |
@@ -180,52 +196,48 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -180,52 +196,48 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
180 | Row( | 196 | Row( |
181 | children: <Widget>[ | 197 | children: <Widget>[ |
182 | Container( | 198 | Container( |
183 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
184 | - width: ScreenUtil.getInstance().setWidth(375), | ||
185 | - height: ScreenUtil.getInstance().setHeight(200), | 199 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
200 | + width: ScreenUtil().setWidth(375), | ||
201 | + height: ScreenUtil().setHeight(200), | ||
186 | color: Colors.red, | 202 | color: Colors.red, |
187 | child: Text( | 203 | child: Text( |
188 | - 'My width:${ScreenUtil.getInstance().setWidth(375)}dp', | 204 | + 'My width:${ScreenUtil().setWidth(375)}dp \n' |
205 | + 'My height:${ScreenUtil().setHeight(200)}dp', | ||
189 | style: TextStyle( | 206 | style: TextStyle( |
190 | - color: Colors.white, | ||
191 | - fontSize: ScreenUtil.getInstance().setSp(12)), | 207 | + color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
192 | ), | 208 | ), |
193 | ), | 209 | ), |
194 | Container( | 210 | Container( |
195 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
196 | - width: ScreenUtil.getInstance().setWidth(375), | ||
197 | - height: ScreenUtil.getInstance().setHeight(200), | 211 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
212 | + width: ScreenUtil().setWidth(375), | ||
213 | + height: ScreenUtil().setHeight(200), | ||
198 | color: Colors.blue, | 214 | color: Colors.blue, |
199 | - child: Text('My width:${ScreenUtil.getInstance().setWidth(375)}dp', | 215 | + child: Text( |
216 | + 'My width:${ScreenUtil().setWidth(375)}dp \n' | ||
217 | + 'My height:${ScreenUtil().setHeight(200)}dp', | ||
200 | style: TextStyle( | 218 | style: TextStyle( |
201 | color: Colors.white, | 219 | color: Colors.white, |
202 | - fontSize: ScreenUtil.getInstance().setSp(12))), | 220 | + fontSize: ScreenUtil().setSp(24))), |
203 | ), | 221 | ), |
204 | ], | 222 | ], |
205 | ), | 223 | ), |
206 | Text('Device width:${ScreenUtil.screenWidth}px'), | 224 | Text('Device width:${ScreenUtil.screenWidth}px'), |
207 | Text('Device height:${ScreenUtil.screenHeight}px'), | 225 | Text('Device height:${ScreenUtil.screenHeight}px'), |
226 | + Text('Device width:${ScreenUtil.screenWidthDp}dp'), | ||
227 | + Text('Device height:${ScreenUtil.screenHeightDp}dp'), | ||
208 | Text('Device pixel density:${ScreenUtil.pixelRatio}'), | 228 | Text('Device pixel density:${ScreenUtil.pixelRatio}'), |
209 | - Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'), | ||
210 | - Text('Status bar height:${ScreenUtil.statusBarHeight}px'), | 229 | + Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}dp'), |
230 | + Text('Status bar height:${ScreenUtil.statusBarHeight}dp'), | ||
211 | Text( | 231 | Text( |
212 | - 'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}', | 232 | + 'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}', |
213 | textAlign: TextAlign.center, | 233 | textAlign: TextAlign.center, |
214 | ), | 234 | ), |
215 | Text( | 235 | Text( |
216 | - 'Ratio of actual height dp to design draft px:${ScreenUtil.getInstance().scaleHeight}', | ||
217 | - textAlign: TextAlign.center, | ||
218 | - ), | ||
219 | - Text( | ||
220 | - 'The ratio of font and width to the size of the design:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}', | ||
221 | - textAlign: TextAlign.center, | ||
222 | - ), | ||
223 | - Text( | ||
224 | - 'The ratio of height width to the size of the design:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}', | 236 | + 'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}', |
225 | textAlign: TextAlign.center, | 237 | textAlign: TextAlign.center, |
226 | ), | 238 | ), |
227 | SizedBox( | 239 | SizedBox( |
228 | - height: ScreenUtil.getInstance().setHeight(100), | 240 | + height: ScreenUtil().setHeight(100), |
229 | ), | 241 | ), |
230 | Text('System font scaling factor:${ScreenUtil.textScaleFactor}'), | 242 | Text('System font scaling factor:${ScreenUtil.textScaleFactor}'), |
231 | Column( | 243 | Column( |
@@ -235,27 +247,57 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -235,27 +247,57 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
235 | 'My font size is 24px on the design draft and will not change with the system.', | 247 | 'My font size is 24px on the design draft and will not change with the system.', |
236 | style: TextStyle( | 248 | style: TextStyle( |
237 | color: Colors.black, | 249 | color: Colors.black, |
238 | - fontSize: ScreenUtil.getInstance().setSp(24), | 250 | + fontSize: ScreenUtil().setSp(24), |
239 | )), | 251 | )), |
240 | Text( | 252 | Text( |
241 | 'My font size is 24px on the design draft and will change with the system.', | 253 | 'My font size is 24px on the design draft and will change with the system.', |
242 | style: TextStyle( | 254 | style: TextStyle( |
243 | - color: Colors.black, | ||
244 | - fontSize: ScreenUtil(allowFontScaling: true).setSp(24), | ||
245 | - )), | 255 | + color: Colors.black, |
256 | + fontSize: ScreenUtil() | ||
257 | + .setSp(24, allowFontScalingSelf: true))), | ||
246 | ], | 258 | ], |
247 | ) | 259 | ) |
248 | ], | 260 | ], |
249 | ), | 261 | ), |
250 | ), | 262 | ), |
263 | + floatingActionButton: FloatingActionButton( | ||
264 | + child: Icon(Icons.title), | ||
265 | + onPressed: () { | ||
266 | + ScreenUtil.init(context, | ||
267 | + width: 1500, height: 1334, allowFontScaling: false); | ||
268 | + setState(() {}); | ||
269 | + }, | ||
270 | + ), | ||
251 | ); | 271 | ); |
252 | } | 272 | } |
273 | + | ||
274 | + void printScreenInformation() { | ||
275 | + print('Device width px:${ScreenUtil.screenWidth}'); //Device width | ||
276 | + print('Device height px:${ScreenUtil.screenHeight}'); //Device height | ||
277 | + print( | ||
278 | + 'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
279 | + print( | ||
280 | + 'Bottom safe zone distance dp:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | ||
281 | + print( | ||
282 | + 'Status bar height px:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | ||
283 | + print( | ||
284 | + 'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}'); | ||
285 | + print( | ||
286 | + 'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}'); | ||
287 | + print( | ||
288 | + 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); | ||
289 | + print( | ||
290 | + 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); | ||
291 | + } | ||
292 | +} | ||
293 | + | ||
253 | ``` | 294 | ``` |
254 | 295 | ||
255 | ### example: | 296 | ### example: |
256 | 297 | ||
257 | -[example demo](/example/lib/main_zh.dart) | 298 | +[example demo](/example/lib/main.dart) |
258 | 299 | ||
259 | effect: | 300 | effect: |
260 | 301 | ||
261 | - | 302 | + |
303 | + |
@@ -27,7 +27,7 @@ dependencies: | @@ -27,7 +27,7 @@ dependencies: | ||
27 | flutter: | 27 | flutter: |
28 | sdk: flutter | 28 | sdk: flutter |
29 | # 添加依赖 | 29 | # 添加依赖 |
30 | - flutter_screenutil: ^0.7.0 | 30 | + flutter_screenutil: ^1.0.0 |
31 | ``` | 31 | ``` |
32 | 32 | ||
33 | ### 在每个使用的地方导入包: | 33 | ### 在每个使用的地方导入包: |
@@ -51,13 +51,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -51,13 +51,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
51 | //填入设计稿中设备的屏幕尺寸 | 51 | //填入设计稿中设备的屏幕尺寸 |
52 | 52 | ||
53 | //默认 width : 1080px , height:1920px , allowFontScaling:false | 53 | //默认 width : 1080px , height:1920px , allowFontScaling:false |
54 | -ScreenUtil.instance = ScreenUtil.getInstance()..init(context); | 54 | +ScreenUtil.init(context); |
55 | 55 | ||
56 | //假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) | 56 | //假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) |
57 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 57 | +ScreenUtil.init(context, width: 750, height: 1334); |
58 | 58 | ||
59 | //设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false | 59 | //设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false |
60 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context); | 60 | +ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); |
61 | 61 | ||
62 | ``` | 62 | ``` |
63 | 63 | ||
@@ -67,12 +67,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | @@ -67,12 +67,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | ||
67 | 67 | ||
68 | 传入设计稿的px尺寸: | 68 | 传入设计稿的px尺寸: |
69 | 69 | ||
70 | -根据屏幕宽度适配 `width: ScreenUtil.getInstance().setWidth(540)`, | 70 | +根据屏幕宽度适配 `width: ScreenUtil().setWidth(540)`, |
71 | 71 | ||
72 | -根据屏幕高度适配 `height: ScreenUtil.getInstance().setHeight(200)`, | ||
73 | - | ||
74 | -也可以使用 `ScreenUtil()` 替代 `ScreenUtil.getInstance()`, | ||
75 | -例如:`ScreenUtil().setHeight(200)` | 72 | +根据屏幕高度适配 `height: ScreenUtil().setHeight(200)`, |
76 | 73 | ||
77 | **注意** | 74 | **注意** |
78 | 75 | ||
@@ -83,16 +80,16 @@ setHeight譁ケ豕穂クサ隕∵弍蝨ィ鬮伜コヲ荳願ソ幄。碁る, 蝨ィ菴諠ウ謗ァ蛻カUI荳贋ク螻冗噪 | @@ -83,16 +80,16 @@ setHeight譁ケ豕穂クサ隕∵弍蝨ィ鬮伜コヲ荳願ソ幄。碁る, 蝨ィ菴諠ウ謗ァ蛻カUI荳贋ク螻冗噪 | ||
83 | 例如: | 80 | 例如: |
84 | 81 | ||
85 | ``` | 82 | ``` |
86 | -//长方形: | 83 | +//UI上是长方形: |
87 | Container( | 84 | Container( |
88 | - width: ScreenUtil.getInstance().setWidth(375), | ||
89 | - height: ScreenUtil.getInstance().setHeight(200), | 85 | + width: ScreenUtil().setWidth(375), |
86 | + height: ScreenUtil().setHeight(200), | ||
90 | ), | 87 | ), |
91 | 88 | ||
92 | //如果你想显示一个正方形: | 89 | //如果你想显示一个正方形: |
93 | Container( | 90 | Container( |
94 | - width: ScreenUtil.getInstance().setWidth(300), | ||
95 | - height: ScreenUtil.getInstance().setWidth(300), | 91 | + width: ScreenUtil().setWidth(300), |
92 | + height: ScreenUtil().setWidth(300), | ||
96 | ), | 93 | ), |
97 | ``` | 94 | ``` |
98 | 95 | ||
@@ -101,26 +98,28 @@ Container( | @@ -101,26 +98,28 @@ Container( | ||
101 | 98 | ||
102 | ``` | 99 | ``` |
103 | //传入字体大小,默认不根据系统的“字体大小”辅助选项来进行缩放(可在初始化ScreenUtil时设置allowFontScaling) | 100 | //传入字体大小,默认不根据系统的“字体大小”辅助选项来进行缩放(可在初始化ScreenUtil时设置allowFontScaling) |
104 | -ScreenUtil.getInstance().setSp(28) | 101 | +ScreenUtil().setSp(28) |
105 | 102 | ||
106 | -//传入字体大小,根据系统的“字体大小”辅助选项来进行缩放(如果某个地方不遵循全局的allowFontScaling设置) | ||
107 | -ScreenUtil(allowFontScaling: true).setSp(28) | ||
108 | - | 103 | +//传入字体大小,根据系统的“字体大小”辅助选项来进行缩放(如果某个地方不遵循全局的allowFontScaling设置) |
104 | +ScreenUtil().setSp(24, allowFontScalingSelf: true) | ||
105 | + | ||
109 | //for example: | 106 | //for example: |
110 | 107 | ||
111 | Column( | 108 | Column( |
112 | crossAxisAlignment: CrossAxisAlignment.start, | 109 | crossAxisAlignment: CrossAxisAlignment.start, |
113 | children: <Widget>[ | 110 | children: <Widget>[ |
114 | - Text('我的文字大小在设计稿上是25px,不会随着系统的文字缩放比例变化', | 111 | + Text('我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化', |
115 | style: TextStyle( | 112 | style: TextStyle( |
116 | - color: Colors.black, fontSize: ScreenUtil.getInstance().setSp(24))), | ||
117 | - Text('我的文字大小在设计稿上是25px,会随着系统的文字缩放比例变化', | 113 | + color: Colors.black, |
114 | + fontSize: ScreenUtil().setSp(24), | ||
115 | + )), | ||
116 | + Text('我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化', | ||
118 | style: TextStyle( | 117 | style: TextStyle( |
119 | - color: Colors.black, fontSize: ScreenUtil(allowFontScaling: true).setSp(24))), | 118 | + color: Colors.black, |
119 | + fontSize: ScreenUtil() | ||
120 | + .setSp(24, allowFontScalingSelf: true))), | ||
120 | ], | 121 | ], |
121 | ) | 122 | ) |
122 | - | ||
123 | - | ||
124 | ``` | 123 | ``` |
125 | 124 | ||
126 | #### 其他相关api: | 125 | #### 其他相关api: |
@@ -132,39 +131,65 @@ Column( | @@ -132,39 +131,65 @@ Column( | ||
132 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px | 131 | ScreenUtil.statusBarHeight //状态栏高度 刘海屏会更高 单位px |
133 | ScreenUtil.textScaleFactor //系统字体缩放比例 | 132 | ScreenUtil.textScaleFactor //系统字体缩放比例 |
134 | 133 | ||
135 | - ScreenUtil.getInstance().scaleWidth // 实际宽度的dp与设计稿px的比例 | ||
136 | - ScreenUtil.getInstance().scaleHeight // 实际高度的dp与设计稿px的比例 | 134 | + ScreenUtil().scaleWidth // 实际宽度的dp与设计稿px的比例 |
135 | + ScreenUtil().scaleHeight // 实际高度的dp与设计稿px的比例 | ||
137 | 136 | ||
138 | ``` | 137 | ``` |
139 | 138 | ||
140 | ```dart | 139 | ```dart |
141 | -//导入 | 140 | +import 'package:flutter/material.dart'; |
142 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 141 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
143 | 142 | ||
144 | -... | ||
145 | - | 143 | +void main() => runApp(new MyApp()); |
144 | + | ||
145 | +class MyApp extends StatelessWidget { | ||
146 | @override | 146 | @override |
147 | Widget build(BuildContext context) { | 147 | Widget build(BuildContext context) { |
148 | - //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) | ||
149 | - ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | ||
150 | - | ||
151 | - print('设备宽度:${ScreenUtil.screenWidth}'); //Device width | ||
152 | - print('设备高度:${ScreenUtil.screenHeight}'); //Device height | ||
153 | - print('设备的像素密度:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
154 | - print( | ||
155 | - '底部安全区距离:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | ||
156 | - print( | ||
157 | - '状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px | 148 | + return new MaterialApp( |
149 | + debugShowCheckedModeBanner: false, | ||
150 | + title: 'Flutter_ScreenUtil', | ||
151 | + theme: new ThemeData( | ||
152 | + primarySwatch: Colors.blue, | ||
153 | + ), | ||
154 | + home: new MyHomePage(), | ||
155 | + ); | ||
156 | + } | ||
157 | +} | ||
158 | 158 | ||
159 | - print('实际宽度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleWidth}'); | ||
160 | - print('实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}'); | 159 | +class MyHomePage extends StatefulWidget { |
160 | + MyHomePage({Key key, this.title}) : super(key: key); | ||
161 | 161 | ||
162 | - print( | ||
163 | - '宽度和字体相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}'); | ||
164 | - print( | ||
165 | - '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | ||
166 | - print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'); | 162 | + final String title; |
163 | + | ||
164 | + @override | ||
165 | + _MyHomePageState createState() => new _MyHomePageState(); | ||
166 | +} | ||
167 | + | ||
168 | +class _MyHomePageState extends State<MyHomePage> { | ||
169 | + @override | ||
170 | + Widget build(BuildContext context) { | ||
171 | + //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) | ||
172 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
173 | + ScreenUtil.init(context); | ||
174 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
175 | + | ||
176 | + return ExampleWidget(title: 'FlutterScreenUtil示例'); | ||
177 | + } | ||
178 | +} | ||
179 | + | ||
180 | +class ExampleWidget extends StatefulWidget { | ||
181 | + const ExampleWidget({Key key, this.title}) : super(key: key); | ||
182 | + | ||
183 | + final String title; | ||
184 | + | ||
185 | + @override | ||
186 | + _ExampleWidgetState createState() => _ExampleWidgetState(); | ||
187 | +} | ||
167 | 188 | ||
189 | +class _ExampleWidgetState extends State<ExampleWidget> { | ||
190 | + @override | ||
191 | + Widget build(BuildContext context) { | ||
192 | + printScreenInformation(); | ||
168 | return new Scaffold( | 193 | return new Scaffold( |
169 | appBar: new AppBar( | 194 | appBar: new AppBar( |
170 | title: new Text(widget.title), | 195 | title: new Text(widget.title), |
@@ -176,72 +201,98 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -176,72 +201,98 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
176 | Row( | 201 | Row( |
177 | children: <Widget>[ | 202 | children: <Widget>[ |
178 | Container( | 203 | Container( |
179 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
180 | - width: ScreenUtil.getInstance().setWidth(375), | ||
181 | - height: ScreenUtil.getInstance().setHeight(200), | 204 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
205 | + width: ScreenUtil().setWidth(375), | ||
206 | + height: ScreenUtil().setHeight(200), | ||
182 | color: Colors.red, | 207 | color: Colors.red, |
183 | child: Text( | 208 | child: Text( |
184 | - '我的宽度:${ScreenUtil.getInstance().setWidth(375)}dp', | 209 | + '我的宽度:${ScreenUtil().setWidth(375)}dp \n' |
210 | + '我的高度:${ScreenUtil().setHeight(200)}dp', | ||
185 | style: TextStyle( | 211 | style: TextStyle( |
186 | - color: Colors.white, | ||
187 | - fontSize: ScreenUtil.getInstance().setSp(12), | ||
188 | - ), | 212 | + color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
189 | ), | 213 | ), |
190 | ), | 214 | ), |
191 | Container( | 215 | Container( |
192 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
193 | - width: ScreenUtil.getInstance().setWidth(375), | ||
194 | - height: ScreenUtil.getInstance().setHeight(200), | 216 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
217 | + width: ScreenUtil().setWidth(375), | ||
218 | + height: ScreenUtil().setHeight(200), | ||
195 | color: Colors.blue, | 219 | color: Colors.blue, |
196 | - child: Text('我的宽度:${ScreenUtil.getInstance().setWidth(375)}dp', | 220 | + child: Text( |
221 | + '我的宽度:${ScreenUtil().setWidth(375)}dp \n' | ||
222 | + '我的高度:${ScreenUtil().setHeight(200)}dp', | ||
197 | style: TextStyle( | 223 | style: TextStyle( |
198 | - color: Colors.white, | ||
199 | - fontSize: ScreenUtil.getInstance().setSp(12), | ||
200 | - )), | 224 | + color: Colors.white, |
225 | + fontSize: ScreenUtil().setSp(24))), | ||
201 | ), | 226 | ), |
202 | ], | 227 | ], |
203 | ), | 228 | ), |
204 | Text('设备宽度:${ScreenUtil.screenWidth}px'), | 229 | Text('设备宽度:${ScreenUtil.screenWidth}px'), |
205 | Text('设备高度:${ScreenUtil.screenHeight}px'), | 230 | Text('设备高度:${ScreenUtil.screenHeight}px'), |
231 | + Text('设备宽度:${ScreenUtil.screenWidthDp}dp'), | ||
232 | + Text('设备高度:${ScreenUtil.screenHeightDp}dp'), | ||
206 | Text('设备的像素密度:${ScreenUtil.pixelRatio}'), | 233 | Text('设备的像素密度:${ScreenUtil.pixelRatio}'), |
207 | - Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'), | ||
208 | - Text('状态栏高度:${ScreenUtil.statusBarHeight}px'), | ||
209 | - Text( | ||
210 | - '实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}', | ||
211 | - textAlign: TextAlign.center, | ||
212 | - ), | 234 | + Text('底部安全区距离:${ScreenUtil.bottomBarHeight}dp'), |
235 | + Text('状态栏高度:${ScreenUtil.statusBarHeight}dp'), | ||
213 | Text( | 236 | Text( |
214 | - '实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}', | 237 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth}', |
215 | textAlign: TextAlign.center, | 238 | textAlign: TextAlign.center, |
216 | ), | 239 | ), |
217 | Text( | 240 | Text( |
218 | - '宽度和字体相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}', | ||
219 | - textAlign: TextAlign.center, | ||
220 | - ), | ||
221 | - Text( | ||
222 | - '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}', | 241 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight}', |
223 | textAlign: TextAlign.center, | 242 | textAlign: TextAlign.center, |
224 | ), | 243 | ), |
225 | SizedBox( | 244 | SizedBox( |
226 | - height: ScreenUtil.getInstance().setHeight(100), | 245 | + height: ScreenUtil().setHeight(100), |
227 | ), | 246 | ), |
228 | Text('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'), | 247 | Text('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'), |
229 | Column( | 248 | Column( |
230 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
231 | - children: <Widget>[ | ||
232 | - Text('我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化', | ||
233 | - style: TextStyle( | ||
234 | - color: Colors.black, fontSize: ScreenUtil.getInstance().setSp(24))), | ||
235 | - Text('我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化', | ||
236 | - style: TextStyle( | ||
237 | - color: Colors.black, fontSize: ScreenUtil(allowFontScaling: true).setSp(24))), | ||
238 | - ], | ||
239 | - ) | 249 | + crossAxisAlignment: CrossAxisAlignment.start, |
250 | + children: <Widget>[ | ||
251 | + Text('我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化', | ||
252 | + style: TextStyle( | ||
253 | + color: Colors.black, | ||
254 | + fontSize: ScreenUtil().setSp(24), | ||
255 | + )), | ||
256 | + Text('我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化', | ||
257 | + style: TextStyle( | ||
258 | + color: Colors.black, | ||
259 | + fontSize: ScreenUtil() | ||
260 | + .setSp(24, allowFontScalingSelf: true))), | ||
261 | + ], | ||
262 | + ) | ||
240 | ], | 263 | ], |
241 | ), | 264 | ), |
242 | ), | 265 | ), |
266 | + floatingActionButton: FloatingActionButton( | ||
267 | + child: Icon(Icons.title), | ||
268 | + onPressed: () { | ||
269 | + ScreenUtil.init(context, | ||
270 | + width: 1500, height: 1334, allowFontScaling: false); | ||
271 | + setState(() {}); | ||
272 | + }, | ||
273 | + ), | ||
243 | ); | 274 | ); |
244 | } | 275 | } |
276 | + | ||
277 | + void printScreenInformation() { | ||
278 | + print('设备宽度:${ScreenUtil.screenWidth}'); //Device width | ||
279 | + print('设备高度:${ScreenUtil.screenHeight}'); //Device height | ||
280 | + print('设备的像素密度:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
281 | + print( | ||
282 | + '底部安全区距离:${ScreenUtil.bottomBarHeight}dp'); //Bottom safe zone distance,suitable for buttons with full screen | ||
283 | + print( | ||
284 | + '状态栏高度:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | ||
285 | + | ||
286 | + print('实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth}'); | ||
287 | + print('实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight}'); | ||
288 | + | ||
289 | + print( | ||
290 | + '宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); | ||
291 | + print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); | ||
292 | + print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'); | ||
293 | + } | ||
294 | +} | ||
295 | + | ||
245 | ``` | 296 | ``` |
246 | 297 | ||
247 | ### 使用示例: | 298 | ### 使用示例: |
@@ -250,5 +301,5 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -250,5 +301,5 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
250 | 301 | ||
251 | 效果: | 302 | 效果: |
252 | 303 | ||
253 | - | ||
254 | - | 304 | + |
305 | + |
@@ -23,7 +23,7 @@ dependencies: | @@ -23,7 +23,7 @@ dependencies: | ||
23 | flutter: | 23 | flutter: |
24 | sdk: flutter | 24 | sdk: flutter |
25 | # add flutter_screenutil | 25 | # add flutter_screenutil |
26 | - flutter_screenutil: ^0.7.0 | 26 | + flutter_screenutil: ^1.0.0 |
27 | ``` | 27 | ``` |
28 | 28 | ||
29 | ### Adicione o seguinte import em seu código Dart: | 29 | ### Adicione o seguinte import em seu código Dart: |
@@ -48,13 +48,13 @@ Certifique-se de definir as dimensões na paginal inicial do MaterialApp (ou sej | @@ -48,13 +48,13 @@ Certifique-se de definir as dimensões na paginal inicial do MaterialApp (ou sej | ||
48 | //Preencha o tamanho da tela do dispositivo no protótipo de design | 48 | //Preencha o tamanho da tela do dispositivo no protótipo de design |
49 | 49 | ||
50 | //Valor padrão: width : 1080px , height:1920px , allowFontScaling:false | 50 | //Valor padrão: width : 1080px , height:1920px , allowFontScaling:false |
51 | -ScreenUtil.instance = ScreenUtil.getInstance()..init(context); | 51 | +ScreenUtil.init(context); |
52 | 52 | ||
53 | //Se o design é baseado no iPhone6 (iPhone6 750*1334) | 53 | //Se o design é baseado no iPhone6 (iPhone6 750*1334) |
54 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 54 | +ScreenUtil.init(context, width: 750, height: 1334); |
55 | 55 | ||
56 | //Se você quer definir que o tamanho da fonte seja ajustado de acordo com a opção "tamanho da fonte" na acessibilidade do sistema | 56 | //Se você quer definir que o tamanho da fonte seja ajustado de acordo com a opção "tamanho da fonte" na acessibilidade do sistema |
57 | -ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context); | 57 | +ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); |
58 | 58 | ||
59 | ``` | 59 | ``` |
60 | 60 | ||
@@ -64,12 +64,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | @@ -64,12 +64,9 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: tru | ||
64 | 64 | ||
65 | Informe o tamanho em pixels do protótipo de design: | 65 | Informe o tamanho em pixels do protótipo de design: |
66 | 66 | ||
67 | -Adaptado à largura da tela: `ScreenUtil.getInstance().setWidth(540)`, | 67 | +Adaptado à largura da tela: `ScreenUtil().setWidth(540)`, |
68 | 68 | ||
69 | -Adaptado à altura da tela: `ScreenUtil.getInstance().setHeight(200)`, | ||
70 | - | ||
71 | -Você também pode utilizar `ScreenUtil()` ao invés de `ScreenUtil.getInstance()`, | ||
72 | -por exemplo:`ScreenUtil().setHeight(200)` | 69 | +Adaptado à altura da tela: `ScreenUtil().setHeight(200)`, |
73 | 70 | ||
74 | **Nota** | 71 | **Nota** |
75 | 72 | ||
@@ -81,15 +78,15 @@ O método setHeight é a principal forma de adaptar a altura, se quiser controla | @@ -81,15 +78,15 @@ O método setHeight é a principal forma de adaptar a altura, se quiser controla | ||
81 | //Exemplo: | 78 | //Exemplo: |
82 | //Retângulo | 79 | //Retângulo |
83 | Container( | 80 | Container( |
84 | - width: ScreenUtil.getInstance().setWidth(375), | ||
85 | - height: ScreenUtil.getInstance().setHeight(200), | 81 | + width: ScreenUtil().setWidth(375), |
82 | + height: ScreenUtil().setHeight(200), | ||
86 | ... | 83 | ... |
87 | ), | 84 | ), |
88 | 85 | ||
89 | ////Se quiser exibir um quadrado: | 86 | ////Se quiser exibir um quadrado: |
90 | Container( | 87 | Container( |
91 | - width: ScreenUtil.getInstance().setWidth(300), | ||
92 | - height: ScreenUtil.getInstance().setWidth(300), | 88 | + width: ScreenUtil().setWidth(300), |
89 | + height: ScreenUtil().setWidth(300), | ||
93 | ), | 90 | ), |
94 | 91 | ||
95 | ``` | 92 | ``` |
@@ -98,11 +95,11 @@ Container( | @@ -98,11 +95,11 @@ Container( | ||
98 | ``` dart | 95 | ``` dart |
99 | //Tamanho da fonte informado, em pixels, a fonte não irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade | 96 | //Tamanho da fonte informado, em pixels, a fonte não irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade |
100 | //(allowFontScaling quando iniciar o ScreenUtil) | 97 | //(allowFontScaling quando iniciar o ScreenUtil) |
101 | -ScreenUtil.getInstance().setSp(28) | 98 | +ScreenUtil().setSp(28) |
102 | 99 | ||
103 | //Tamanho da fonte informado,em pixels,a fonte irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade | 100 | //Tamanho da fonte informado,em pixels,a fonte irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade |
104 | //(Se em algum lugar não seguir a configuração global da propriedade allowFontScaling) | 101 | //(Se em algum lugar não seguir a configuração global da propriedade allowFontScaling) |
105 | -ScreenUtil(allowFontScaling: true).setSp(28) | 102 | +ScreenUtil().setSp(24, allowFontScalingSelf: true) |
106 | 103 | ||
107 | //Exemplo: | 104 | //Exemplo: |
108 | 105 | ||
@@ -113,18 +110,16 @@ Column( | @@ -113,18 +110,16 @@ Column( | ||
113 | 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', | 110 | 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', |
114 | style: TextStyle( | 111 | style: TextStyle( |
115 | color: Colors.black, | 112 | color: Colors.black, |
116 | - fontSize: ScreenUtil.getInstance().setSp(24), | 113 | + fontSize: ScreenUtil().setSp(24), |
117 | )), | 114 | )), |
118 | Text( | 115 | Text( |
119 | 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', | 116 | 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', |
120 | style: TextStyle( | 117 | style: TextStyle( |
121 | - color: Colors.black, | ||
122 | - fontSize: ScreenUtil(allowFontScaling: true).setSp(24), | ||
123 | - )), | 118 | + color: Colors.black, |
119 | + fontSize: ScreenUtil() | ||
120 | + .setSp(24, allowFontScalingSelf: true))), | ||
124 | ], | 121 | ], |
125 | ) | 122 | ) |
126 | - | ||
127 | - | ||
128 | ``` | 123 | ``` |
129 | 124 | ||
130 | #### Outras APIs relacionadas: | 125 | #### Outras APIs relacionadas: |
@@ -136,8 +131,8 @@ Column( | @@ -136,8 +131,8 @@ Column( | ||
136 | ScreenUtil.statusBarHeight //Altura da status bar em pixels, Notch será maior | 131 | ScreenUtil.statusBarHeight //Altura da status bar em pixels, Notch será maior |
137 | ScreenUtil.textScaleFactor //Fator de escala da fonte do sistema | 132 | ScreenUtil.textScaleFactor //Fator de escala da fonte do sistema |
138 | 133 | ||
139 | - ScreenUtil.getInstance().scaleWidth //Razão entre a largura atual e a largura do protótipo de design em pixels | ||
140 | - ScreenUtil.getInstance().scaleHeight //Razão entre a altura atual e a altura do protótipo de design em pixels | 134 | + ScreenUtil().scaleWidth //Razão entre a largura atual e a largura do protótipo de design em pixels |
135 | + ScreenUtil().scaleHeight //Razão entre a altura atual e a altura do protótipo de design em pixels | ||
141 | 136 | ||
142 | ``` | 137 | ``` |
143 | 138 | ||
@@ -150,7 +145,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -150,7 +145,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
150 | @override | 145 | @override |
151 | Widget build(BuildContext context) { | 146 | Widget build(BuildContext context) { |
152 | ///Define o tamanho de ajuste (preenche o tamanho da tela do dispositivo no design). Se o design é baseado no tamanho do iPhone6 (iPhone6 750*1334) | 147 | ///Define o tamanho de ajuste (preenche o tamanho da tela do dispositivo no design). Se o design é baseado no tamanho do iPhone6 (iPhone6 750*1334) |
153 | - ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 148 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); |
154 | 149 | ||
155 | print('Largura do dispositivo:${ScreenUtil.screenWidth}'); //Largura do dispositivo | 150 | print('Largura do dispositivo:${ScreenUtil.screenWidth}'); //Largura do dispositivo |
156 | print('Altura do dispositivo:${ScreenUtil.screenHeight}'); //Altura do dispositivo | 151 | print('Altura do dispositivo:${ScreenUtil.screenHeight}'); //Altura do dispositivo |
@@ -161,13 +156,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -161,13 +156,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
161 | print( | 156 | print( |
162 | 'Altura da status bar:${ScreenUtil.statusBarHeight}px'); //Altura da status bar em pixels, Notch será maior | 157 | 'Altura da status bar:${ScreenUtil.statusBarHeight}px'); //Altura da status bar em pixels, Notch será maior |
163 | print( | 158 | print( |
164 | - 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil.getInstance().scaleWidth}'); | 159 | + 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil().scaleWidth}'); |
165 | print( | 160 | print( |
166 | - 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil.getInstance().scaleHeight}'); | 161 | + 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil().scaleHeight}'); |
167 | print( | 162 | print( |
168 | - 'Razão da fonte e largura para o tamanho do design:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}'); | 163 | + 'Razão da fonte e largura para o tamanho do design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); |
169 | print( | 164 | print( |
170 | - 'Razão da fonte e altura para o tamanho do design:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | 165 | + 'Razão da fonte e altura para o tamanho do design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); |
171 | 166 | ||
172 | return new Scaffold( | 167 | return new Scaffold( |
173 | appBar: new AppBar( | 168 | appBar: new AppBar( |
@@ -180,26 +175,26 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -180,26 +175,26 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
180 | Row( | 175 | Row( |
181 | children: <Widget>[ | 176 | children: <Widget>[ |
182 | Container( | 177 | Container( |
183 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
184 | - width: ScreenUtil.getInstance().setWidth(375), | ||
185 | - height: ScreenUtil.getInstance().setHeight(200), | 178 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
179 | + width: ScreenUtil().setWidth(375), | ||
180 | + height: ScreenUtil().setHeight(200), | ||
186 | color: Colors.red, | 181 | color: Colors.red, |
187 | child: Text( | 182 | child: Text( |
188 | - 'Minha largura:${ScreenUtil.getInstance().setWidth(375)}dp', | 183 | + 'Minha largura:${ScreenUtil().setWidth(375)}dp', |
189 | style: TextStyle( | 184 | style: TextStyle( |
190 | color: Colors.white, | 185 | color: Colors.white, |
191 | - fontSize: ScreenUtil.getInstance().setSp(12)), | 186 | + fontSize: ScreenUtil().setSp(12)), |
192 | ), | 187 | ), |
193 | ), | 188 | ), |
194 | Container( | 189 | Container( |
195 | - padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
196 | - width: ScreenUtil.getInstance().setWidth(375), | ||
197 | - height: ScreenUtil.getInstance().setHeight(200), | 190 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
191 | + width: ScreenUtil().setWidth(375), | ||
192 | + height: ScreenUtil().setHeight(200), | ||
198 | color: Colors.blue, | 193 | color: Colors.blue, |
199 | - child: Text('Minha largura:${ScreenUtil.getInstance().setWidth(375)}dp', | 194 | + child: Text('Minha largura:${ScreenUtil().setWidth(375)}dp', |
200 | style: TextStyle( | 195 | style: TextStyle( |
201 | color: Colors.white, | 196 | color: Colors.white, |
202 | - fontSize: ScreenUtil.getInstance().setSp(12))), | 197 | + fontSize: ScreenUtil().setSp(12))), |
203 | ), | 198 | ), |
204 | ], | 199 | ], |
205 | ), | 200 | ), |
@@ -209,23 +204,23 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -209,23 +204,23 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
209 | Text('Distância segura do rodapé:${ScreenUtil.bottomBarHeight}px'), | 204 | Text('Distância segura do rodapé:${ScreenUtil.bottomBarHeight}px'), |
210 | Text('Altura da status bar:${ScreenUtil.statusBarHeight}px'), | 205 | Text('Altura da status bar:${ScreenUtil.statusBarHeight}px'), |
211 | Text( | 206 | Text( |
212 | - 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil.getInstance().scaleWidth}', | 207 | + 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil().scaleWidth}', |
213 | textAlign: TextAlign.center, | 208 | textAlign: TextAlign.center, |
214 | ), | 209 | ), |
215 | Text( | 210 | Text( |
216 | - 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil.getInstance().scaleHeight}', | 211 | + 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil().scaleHeight}', |
217 | textAlign: TextAlign.center, | 212 | textAlign: TextAlign.center, |
218 | ), | 213 | ), |
219 | Text( | 214 | Text( |
220 | - 'Razão da fonte e largura para o tamanho do design:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}', | 215 | + 'Razão da fonte e largura para o tamanho do design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', |
221 | textAlign: TextAlign.center, | 216 | textAlign: TextAlign.center, |
222 | ), | 217 | ), |
223 | Text( | 218 | Text( |
224 | - 'Razão da fonte e altura para o tamanho do design:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}', | 219 | + 'Razão da fonte e altura para o tamanho do design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', |
225 | textAlign: TextAlign.center, | 220 | textAlign: TextAlign.center, |
226 | ), | 221 | ), |
227 | SizedBox( | 222 | SizedBox( |
228 | - height: ScreenUtil.getInstance().setHeight(100), | 223 | + height: ScreenUtil().setHeight(100), |
229 | ), | 224 | ), |
230 | Text('Fator de escala da fonte do sistema:${ScreenUtil.textScaleFactor}'), | 225 | Text('Fator de escala da fonte do sistema:${ScreenUtil.textScaleFactor}'), |
231 | Column( | 226 | Column( |
@@ -235,13 +230,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -235,13 +230,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
235 | 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', | 230 | 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', |
236 | style: TextStyle( | 231 | style: TextStyle( |
237 | color: Colors.black, | 232 | color: Colors.black, |
238 | - fontSize: ScreenUtil.getInstance().setSp(24), | 233 | + fontSize: ScreenUtil().setSp(24), |
239 | )), | 234 | )), |
240 | Text( | 235 | Text( |
241 | 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', | 236 | 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', |
242 | style: TextStyle( | 237 | style: TextStyle( |
243 | color: Colors.black, | 238 | color: Colors.black, |
244 | - fontSize: ScreenUtil(allowFontScaling: true).setSp(24), | 239 | + fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: true), |
245 | )), | 240 | )), |
246 | ], | 241 | ], |
247 | ) | 242 | ) |
@@ -259,3 +254,4 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -259,3 +254,4 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
259 | Efeito: | 254 | Efeito: |
260 | 255 | ||
261 |  | 256 |  |
257 | + |
demo_tablet_en.png
0 → 100644

258 KB
demo_tablet_zh.png
0 → 100644

295 KB
1 | # example | 1 | # example |
2 | 2 | ||
3 | -flutter_screenutil的使用示例 | 3 | +flutter_screenutil example |
4 | 4 | ||
5 | - | ||
6 | - | 5 | + |
6 | + | ||
7 | 7 | ||
8 | + | ||
9 | + | ||
8 | ## Getting Started | 10 | ## Getting Started |
9 | - | ||
10 | -For help getting started with Flutter, view our online | ||
11 | -[documentation](https://flutter.io/). | 11 | + |
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application' | @@ -25,7 +25,7 @@ apply plugin: 'com.android.application' | ||
25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" |
26 | 26 | ||
27 | android { | 27 | android { |
28 | - compileSdkVersion 27 | 28 | + compileSdkVersion 28 |
29 | 29 | ||
30 | lintOptions { | 30 | lintOptions { |
31 | disable 'InvalidPackage' | 31 | disable 'InvalidPackage' |
@@ -35,7 +35,7 @@ android { | @@ -35,7 +35,7 @@ android { | ||
35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). |
36 | applicationId "li.zhuoyuan.example" | 36 | applicationId "li.zhuoyuan.example" |
37 | minSdkVersion 16 | 37 | minSdkVersion 16 |
38 | - targetSdkVersion 27 | 38 | + targetSdkVersion 28 |
39 | versionCode flutterVersionCode.toInteger() | 39 | versionCode flutterVersionCode.toInteger() |
40 | versionName flutterVersionName | 40 | versionName flutterVersionName |
41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
@@ -4,7 +4,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -4,7 +4,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
4 | void main() => runApp(new MyApp()); | 4 | void main() => runApp(new MyApp()); |
5 | 5 | ||
6 | class MyApp extends StatelessWidget { | 6 | class MyApp extends StatelessWidget { |
7 | - // This widget is the root of your application. | ||
8 | @override | 7 | @override |
9 | Widget build(BuildContext context) { | 8 | Widget build(BuildContext context) { |
10 | return new MaterialApp( | 9 | return new MaterialApp( |
@@ -13,16 +12,12 @@ class MyApp extends StatelessWidget { | @@ -13,16 +12,12 @@ class MyApp extends StatelessWidget { | ||
13 | theme: new ThemeData( | 12 | theme: new ThemeData( |
14 | primarySwatch: Colors.blue, | 13 | primarySwatch: Colors.blue, |
15 | ), | 14 | ), |
16 | - home: new MyHomePage(title: 'FlutterScreenUtil Demo'), | 15 | + home: new MyHomePage(), |
17 | ); | 16 | ); |
18 | } | 17 | } |
19 | } | 18 | } |
20 | 19 | ||
21 | class MyHomePage extends StatefulWidget { | 20 | class MyHomePage extends StatefulWidget { |
22 | - MyHomePage({Key key, this.title}) : super(key: key); | ||
23 | - | ||
24 | - final String title; | ||
25 | - | ||
26 | @override | 21 | @override |
27 | _MyHomePageState createState() => new _MyHomePageState(); | 22 | _MyHomePageState createState() => new _MyHomePageState(); |
28 | } | 23 | } |
@@ -30,26 +25,26 @@ class MyHomePage extends StatefulWidget { | @@ -30,26 +25,26 @@ class MyHomePage extends StatefulWidget { | ||
30 | class _MyHomePageState extends State<MyHomePage> { | 25 | class _MyHomePageState extends State<MyHomePage> { |
31 | @override | 26 | @override |
32 | Widget build(BuildContext context) { | 27 | Widget build(BuildContext context) { |
33 | - ///Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334) | ||
34 | - ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | 28 | + //Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334) |
29 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
35 | 30 | ||
36 | - print('Device width px:${ScreenUtil.screenWidth}'); //Device width | ||
37 | - print('Device height px:${ScreenUtil.screenHeight}'); //Device height | ||
38 | - print( | ||
39 | - 'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
40 | - print( | ||
41 | - 'Bottom safe zone distance dp:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | ||
42 | - print( | ||
43 | - 'Status bar height px:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | ||
44 | - print( | ||
45 | - 'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}'); | ||
46 | - print( | ||
47 | - 'Ratio of actual height dp to design draft px:${ScreenUtil.getInstance().scaleHeight}'); | ||
48 | - print( | ||
49 | - 'The ratio of font and width to the size of the design:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}'); | ||
50 | - print( | ||
51 | - 'The ratio of height width to the size of the design:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | 31 | + return ExampleWidget(title: 'FlutterScreenUtil Demo'); |
32 | + } | ||
33 | +} | ||
34 | + | ||
35 | +class ExampleWidget extends StatefulWidget { | ||
36 | + const ExampleWidget({Key key, this.title}) : super(key: key); | ||
37 | + | ||
38 | + final String title; | ||
39 | + | ||
40 | + @override | ||
41 | + _ExampleWidgetState createState() => _ExampleWidgetState(); | ||
42 | +} | ||
52 | 43 | ||
44 | +class _ExampleWidgetState extends State<ExampleWidget> { | ||
45 | + @override | ||
46 | + Widget build(BuildContext context) { | ||
47 | + printScreenInformation(); | ||
53 | return new Scaffold( | 48 | return new Scaffold( |
54 | appBar: new AppBar( | 49 | appBar: new AppBar( |
55 | title: new Text(widget.title), | 50 | title: new Text(widget.title), |
@@ -61,29 +56,28 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -61,29 +56,28 @@ class _MyHomePageState extends State<MyHomePage> { | ||
61 | Row( | 56 | Row( |
62 | children: <Widget>[ | 57 | children: <Widget>[ |
63 | Container( | 58 | Container( |
64 | - padding: | ||
65 | - EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
66 | - width: ScreenUtil.getInstance().setWidth(375), | ||
67 | - height: ScreenUtil.getInstance().setHeight(200), | 59 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
60 | + width: ScreenUtil().setWidth(375), | ||
61 | + height: ScreenUtil().setHeight(200), | ||
68 | color: Colors.red, | 62 | color: Colors.red, |
69 | child: Text( | 63 | child: Text( |
70 | - 'My width:${ScreenUtil.getInstance().setWidth(375)}dp', | 64 | + 'My width:${ScreenUtil().setWidth(375)}dp \n' |
65 | + 'My height:${ScreenUtil().setHeight(200)}dp', | ||
71 | style: TextStyle( | 66 | style: TextStyle( |
72 | - color: Colors.white, | ||
73 | - fontSize: ScreenUtil.getInstance().setSp(24)), | 67 | + color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
74 | ), | 68 | ), |
75 | ), | 69 | ), |
76 | Container( | 70 | Container( |
77 | - padding: | ||
78 | - EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
79 | - width: ScreenUtil.getInstance().setWidth(375), | ||
80 | - height: ScreenUtil.getInstance().setHeight(200), | 71 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
72 | + width: ScreenUtil().setWidth(375), | ||
73 | + height: ScreenUtil().setHeight(200), | ||
81 | color: Colors.blue, | 74 | color: Colors.blue, |
82 | child: Text( | 75 | child: Text( |
83 | - 'My width:${ScreenUtil.getInstance().setWidth(375)}dp', | 76 | + 'My width:${ScreenUtil().setWidth(375)}dp \n' |
77 | + 'My height:${ScreenUtil().setHeight(200)}dp', | ||
84 | style: TextStyle( | 78 | style: TextStyle( |
85 | color: Colors.white, | 79 | color: Colors.white, |
86 | - fontSize: ScreenUtil.getInstance().setSp(24))), | 80 | + fontSize: ScreenUtil().setSp(24))), |
87 | ), | 81 | ), |
88 | ], | 82 | ], |
89 | ), | 83 | ), |
@@ -95,15 +89,15 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -95,15 +89,15 @@ class _MyHomePageState extends State<MyHomePage> { | ||
95 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}dp'), | 89 | Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}dp'), |
96 | Text('Status bar height:${ScreenUtil.statusBarHeight}dp'), | 90 | Text('Status bar height:${ScreenUtil.statusBarHeight}dp'), |
97 | Text( | 91 | Text( |
98 | - 'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}', | 92 | + 'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}', |
99 | textAlign: TextAlign.center, | 93 | textAlign: TextAlign.center, |
100 | ), | 94 | ), |
101 | Text( | 95 | Text( |
102 | - 'Ratio of actual height dp to design draft px:${ScreenUtil.getInstance().scaleHeight}', | 96 | + 'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}', |
103 | textAlign: TextAlign.center, | 97 | textAlign: TextAlign.center, |
104 | ), | 98 | ), |
105 | SizedBox( | 99 | SizedBox( |
106 | - height: ScreenUtil.getInstance().setHeight(100), | 100 | + height: ScreenUtil().setHeight(100), |
107 | ), | 101 | ), |
108 | Text('System font scaling factor:${ScreenUtil.textScaleFactor}'), | 102 | Text('System font scaling factor:${ScreenUtil.textScaleFactor}'), |
109 | Column( | 103 | Column( |
@@ -113,19 +107,46 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -113,19 +107,46 @@ class _MyHomePageState extends State<MyHomePage> { | ||
113 | 'My font size is 24px on the design draft and will not change with the system.', | 107 | 'My font size is 24px on the design draft and will not change with the system.', |
114 | style: TextStyle( | 108 | style: TextStyle( |
115 | color: Colors.black, | 109 | color: Colors.black, |
116 | - fontSize: ScreenUtil.getInstance().setSp(24), | 110 | + fontSize: ScreenUtil().setSp(24), |
117 | )), | 111 | )), |
118 | Text( | 112 | Text( |
119 | 'My font size is 24px on the design draft and will change with the system.', | 113 | 'My font size is 24px on the design draft and will change with the system.', |
120 | style: TextStyle( | 114 | style: TextStyle( |
121 | - color: Colors.black, | ||
122 | - fontSize: ScreenUtil(allowFontScaling: true).setSp(24), | ||
123 | - )), | 115 | + color: Colors.black, |
116 | + fontSize: ScreenUtil() | ||
117 | + .setSp(24, allowFontScalingSelf: true))), | ||
124 | ], | 118 | ], |
125 | ) | 119 | ) |
126 | ], | 120 | ], |
127 | ), | 121 | ), |
128 | ), | 122 | ), |
123 | + floatingActionButton: FloatingActionButton( | ||
124 | + child: Icon(Icons.title), | ||
125 | + onPressed: () { | ||
126 | + ScreenUtil.init(context, | ||
127 | + width: 1500, height: 1334, allowFontScaling: false); | ||
128 | + setState(() {}); | ||
129 | + }, | ||
130 | + ), | ||
129 | ); | 131 | ); |
130 | } | 132 | } |
133 | + | ||
134 | + void printScreenInformation() { | ||
135 | + print('Device width px:${ScreenUtil.screenWidth}'); //Device width | ||
136 | + print('Device height px:${ScreenUtil.screenHeight}'); //Device height | ||
137 | + print( | ||
138 | + 'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
139 | + print( | ||
140 | + 'Bottom safe zone distance dp:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | ||
141 | + print( | ||
142 | + 'Status bar height px:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | ||
143 | + print( | ||
144 | + 'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}'); | ||
145 | + print( | ||
146 | + 'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}'); | ||
147 | + print( | ||
148 | + 'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); | ||
149 | + print( | ||
150 | + 'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); | ||
151 | + } | ||
131 | } | 152 | } |
@@ -4,7 +4,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -4,7 +4,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
4 | void main() => runApp(new MyApp()); | 4 | void main() => runApp(new MyApp()); |
5 | 5 | ||
6 | class MyApp extends StatelessWidget { | 6 | class MyApp extends StatelessWidget { |
7 | - // This widget is the root of your application. | ||
8 | @override | 7 | @override |
9 | Widget build(BuildContext context) { | 8 | Widget build(BuildContext context) { |
10 | return new MaterialApp( | 9 | return new MaterialApp( |
@@ -13,7 +12,7 @@ class MyApp extends StatelessWidget { | @@ -13,7 +12,7 @@ class MyApp extends StatelessWidget { | ||
13 | theme: new ThemeData( | 12 | theme: new ThemeData( |
14 | primarySwatch: Colors.blue, | 13 | primarySwatch: Colors.blue, |
15 | ), | 14 | ), |
16 | - home: new MyHomePage(title: 'FlutterScreenUtil Demo'), | 15 | + home: new MyHomePage(), |
17 | ); | 16 | ); |
18 | } | 17 | } |
19 | } | 18 | } |
@@ -30,36 +29,31 @@ class MyHomePage extends StatefulWidget { | @@ -30,36 +29,31 @@ class MyHomePage extends StatefulWidget { | ||
30 | class _MyHomePageState extends State<MyHomePage> { | 29 | class _MyHomePageState extends State<MyHomePage> { |
31 | @override | 30 | @override |
32 | Widget build(BuildContext context) { | 31 | Widget build(BuildContext context) { |
33 | - //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) | ||
34 | - ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | ||
35 | - print('设备宽度:${ScreenUtil.screenWidth}'); //Device width | ||
36 | - print('设备高度:${ScreenUtil.screenHeight}'); //Device height | ||
37 | - print('设备的像素密度:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
38 | - print( | ||
39 | - '底部安全区距离:${ScreenUtil.bottomBarHeight}dp'); //Bottom safe zone distance,suitable for buttons with full screen | ||
40 | - print( | ||
41 | - '状态栏高度:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | 32 | + //设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334) |
33 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
34 | + ScreenUtil.init(context); | ||
35 | + ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false); | ||
42 | 36 | ||
43 | - print('实际宽度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleWidth}'); | ||
44 | - print('实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}'); | 37 | + return ExampleWidget(title: 'FlutterScreenUtil示例'); |
38 | + } | ||
39 | +} | ||
45 | 40 | ||
46 | - print( | ||
47 | - '宽度和字体相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}'); | ||
48 | - print( | ||
49 | - '高度相对于设计稿放大的比例:${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}'); | ||
50 | - print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'); | 41 | +class ExampleWidget extends StatefulWidget { |
42 | + const ExampleWidget({Key key, this.title}) : super(key: key); | ||
51 | 43 | ||
52 | - return Scaffold( | ||
53 | - appBar: AppBar( | ||
54 | - title: Text(widget.title), | ||
55 | - ), | ||
56 | - floatingActionButton: FloatingActionButton( | ||
57 | - onPressed: () { | ||
58 | - print( | ||
59 | - 'ScreenUtil.getInstance().width:${ScreenUtil.getInstance().width}'); | ||
60 | - print('ScreenUtil().width:${ScreenUtil().width}'); | ||
61 | - }, | ||
62 | - child: Icon(Icons.accessible_forward), | 44 | + final String title; |
45 | + | ||
46 | + @override | ||
47 | + _ExampleWidgetState createState() => _ExampleWidgetState(); | ||
48 | +} | ||
49 | + | ||
50 | +class _ExampleWidgetState extends State<ExampleWidget> { | ||
51 | + @override | ||
52 | + Widget build(BuildContext context) { | ||
53 | + printScreenInformation(); | ||
54 | + return new Scaffold( | ||
55 | + appBar: new AppBar( | ||
56 | + title: new Text(widget.title), | ||
63 | ), | 57 | ), |
64 | body: new Center( | 58 | body: new Center( |
65 | child: Column( | 59 | child: Column( |
@@ -68,31 +62,28 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -68,31 +62,28 @@ class _MyHomePageState extends State<MyHomePage> { | ||
68 | Row( | 62 | Row( |
69 | children: <Widget>[ | 63 | children: <Widget>[ |
70 | Container( | 64 | Container( |
71 | - padding: | ||
72 | - EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
73 | - width: ScreenUtil.getInstance().setWidth(375), | ||
74 | - height: ScreenUtil.getInstance().setHeight(200), | 65 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
66 | + width: ScreenUtil().setWidth(375), | ||
67 | + height: ScreenUtil().setHeight(200), | ||
75 | color: Colors.red, | 68 | color: Colors.red, |
76 | child: Text( | 69 | child: Text( |
77 | - '我的宽度:${ScreenUtil.getInstance().setWidth(375)}dp', | 70 | + '我的宽度:${ScreenUtil().setWidth(375)}dp \n' |
71 | + '我的高度:${ScreenUtil().setHeight(200)}dp', | ||
78 | style: TextStyle( | 72 | style: TextStyle( |
79 | - color: Colors.white, | ||
80 | - fontSize: ScreenUtil.getInstance().setSp(24), | ||
81 | - ), | 73 | + color: Colors.white, fontSize: ScreenUtil().setSp(24)), |
82 | ), | 74 | ), |
83 | ), | 75 | ), |
84 | Container( | 76 | Container( |
85 | - padding: | ||
86 | - EdgeInsets.all(ScreenUtil.getInstance().setWidth(10)), | ||
87 | - width: ScreenUtil.getInstance().setWidth(375), | ||
88 | - height: ScreenUtil.getInstance().setHeight(200), | 77 | + padding: EdgeInsets.all(ScreenUtil().setWidth(10)), |
78 | + width: ScreenUtil().setWidth(375), | ||
79 | + height: ScreenUtil().setHeight(200), | ||
89 | color: Colors.blue, | 80 | color: Colors.blue, |
90 | - child: | ||
91 | - Text('我的宽度:${ScreenUtil.getInstance().setWidth(375)}dp', | ||
92 | - style: TextStyle( | ||
93 | - color: Colors.white, | ||
94 | - fontSize: ScreenUtil.getInstance().setSp(24), | ||
95 | - )), | 81 | + child: Text( |
82 | + '我的宽度:${ScreenUtil().setWidth(375)}dp \n' | ||
83 | + '我的高度:${ScreenUtil().setHeight(200)}dp', | ||
84 | + style: TextStyle( | ||
85 | + color: Colors.white, | ||
86 | + fontSize: ScreenUtil().setSp(24))), | ||
96 | ), | 87 | ), |
97 | ], | 88 | ], |
98 | ), | 89 | ), |
@@ -100,20 +91,19 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -100,20 +91,19 @@ class _MyHomePageState extends State<MyHomePage> { | ||
100 | Text('设备高度:${ScreenUtil.screenHeight}px'), | 91 | Text('设备高度:${ScreenUtil.screenHeight}px'), |
101 | Text('设备宽度:${ScreenUtil.screenWidthDp}dp'), | 92 | Text('设备宽度:${ScreenUtil.screenWidthDp}dp'), |
102 | Text('设备高度:${ScreenUtil.screenHeightDp}dp'), | 93 | Text('设备高度:${ScreenUtil.screenHeightDp}dp'), |
103 | - Text('设计稿宽度:${ScreenUtil.getInstance().width}'), | ||
104 | Text('设备的像素密度:${ScreenUtil.pixelRatio}'), | 94 | Text('设备的像素密度:${ScreenUtil.pixelRatio}'), |
105 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}dp'), | 95 | Text('底部安全区距离:${ScreenUtil.bottomBarHeight}dp'), |
106 | Text('状态栏高度:${ScreenUtil.statusBarHeight}dp'), | 96 | Text('状态栏高度:${ScreenUtil.statusBarHeight}dp'), |
107 | Text( | 97 | Text( |
108 | - '实际宽度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleWidth}', | 98 | + '实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth}', |
109 | textAlign: TextAlign.center, | 99 | textAlign: TextAlign.center, |
110 | ), | 100 | ), |
111 | Text( | 101 | Text( |
112 | - '实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}', | 102 | + '实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight}', |
113 | textAlign: TextAlign.center, | 103 | textAlign: TextAlign.center, |
114 | ), | 104 | ), |
115 | SizedBox( | 105 | SizedBox( |
116 | - height: ScreenUtil.getInstance().setHeight(100), | 106 | + height: ScreenUtil().setHeight(100), |
117 | ), | 107 | ), |
118 | Text('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'), | 108 | Text('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'), |
119 | Column( | 109 | Column( |
@@ -121,18 +111,45 @@ class _MyHomePageState extends State<MyHomePage> { | @@ -121,18 +111,45 @@ class _MyHomePageState extends State<MyHomePage> { | ||
121 | children: <Widget>[ | 111 | children: <Widget>[ |
122 | Text('我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化', | 112 | Text('我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化', |
123 | style: TextStyle( | 113 | style: TextStyle( |
124 | - color: Colors.black, | ||
125 | - fontSize: ScreenUtil.getInstance().setSp(24))), | 114 | + color: Colors.black, |
115 | + fontSize: ScreenUtil().setSp(24), | ||
116 | + )), | ||
126 | Text('我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化', | 117 | Text('我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化', |
127 | style: TextStyle( | 118 | style: TextStyle( |
128 | color: Colors.black, | 119 | color: Colors.black, |
129 | - fontSize: | ||
130 | - ScreenUtil(allowFontScaling: true).setSp(24))), | 120 | + fontSize: ScreenUtil() |
121 | + .setSp(24, allowFontScalingSelf: true))), | ||
131 | ], | 122 | ], |
132 | ) | 123 | ) |
133 | ], | 124 | ], |
134 | ), | 125 | ), |
135 | ), | 126 | ), |
127 | + floatingActionButton: FloatingActionButton( | ||
128 | + child: Icon(Icons.title), | ||
129 | + onPressed: () { | ||
130 | + ScreenUtil.init(context, | ||
131 | + width: 1500, height: 1334, allowFontScaling: false); | ||
132 | + setState(() {}); | ||
133 | + }, | ||
134 | + ), | ||
136 | ); | 135 | ); |
137 | } | 136 | } |
137 | + | ||
138 | + void printScreenInformation() { | ||
139 | + print('设备宽度:${ScreenUtil.screenWidth}'); //Device width | ||
140 | + print('设备高度:${ScreenUtil.screenHeight}'); //Device height | ||
141 | + print('设备的像素密度:${ScreenUtil.pixelRatio}'); //Device pixel density | ||
142 | + print( | ||
143 | + '底部安全区距离:${ScreenUtil.bottomBarHeight}dp'); //Bottom safe zone distance,suitable for buttons with full screen | ||
144 | + print( | ||
145 | + '状态栏高度:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | ||
146 | + | ||
147 | + print('实际宽度的dp与设计稿px的比例:${ScreenUtil().scaleWidth}'); | ||
148 | + print('实际高度的dp与设计稿px的比例:${ScreenUtil().scaleHeight}'); | ||
149 | + | ||
150 | + print( | ||
151 | + '宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); | ||
152 | + print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); | ||
153 | + print('系统的字体缩放比例:${ScreenUtil.textScaleFactor}'); | ||
154 | + } | ||
138 | } | 155 | } |
1 | # Generated by pub | 1 | # Generated by pub |
2 | # See https://dart.dev/tools/pub/glossary#lockfile | 2 | # See https://dart.dev/tools/pub/glossary#lockfile |
3 | packages: | 3 | packages: |
4 | + archive: | ||
5 | + dependency: transitive | ||
6 | + description: | ||
7 | + name: archive | ||
8 | + url: "https://pub.dartlang.org" | ||
9 | + source: hosted | ||
10 | + version: "2.0.11" | ||
11 | + args: | ||
12 | + dependency: transitive | ||
13 | + description: | ||
14 | + name: args | ||
15 | + url: "https://pub.dartlang.org" | ||
16 | + source: hosted | ||
17 | + version: "1.5.2" | ||
4 | async: | 18 | async: |
5 | dependency: transitive | 19 | dependency: transitive |
6 | description: | 20 | description: |
7 | name: async | 21 | name: async |
8 | - url: "https://pub.flutter-io.cn" | 22 | + url: "https://pub.dartlang.org" |
9 | source: hosted | 23 | source: hosted |
10 | - version: "2.3.0" | 24 | + version: "2.4.0" |
11 | boolean_selector: | 25 | boolean_selector: |
12 | dependency: transitive | 26 | dependency: transitive |
13 | description: | 27 | description: |
14 | name: boolean_selector | 28 | name: boolean_selector |
15 | - url: "https://pub.flutter-io.cn" | 29 | + url: "https://pub.dartlang.org" |
16 | source: hosted | 30 | source: hosted |
17 | version: "1.0.5" | 31 | version: "1.0.5" |
18 | charcode: | 32 | charcode: |
19 | dependency: transitive | 33 | dependency: transitive |
20 | description: | 34 | description: |
21 | name: charcode | 35 | name: charcode |
22 | - url: "https://pub.flutter-io.cn" | 36 | + url: "https://pub.dartlang.org" |
23 | source: hosted | 37 | source: hosted |
24 | version: "1.1.2" | 38 | version: "1.1.2" |
25 | collection: | 39 | collection: |
26 | dependency: transitive | 40 | dependency: transitive |
27 | description: | 41 | description: |
28 | name: collection | 42 | name: collection |
29 | - url: "https://pub.flutter-io.cn" | 43 | + url: "https://pub.dartlang.org" |
30 | source: hosted | 44 | source: hosted |
31 | version: "1.14.11" | 45 | version: "1.14.11" |
46 | + convert: | ||
47 | + dependency: transitive | ||
48 | + description: | ||
49 | + name: convert | ||
50 | + url: "https://pub.dartlang.org" | ||
51 | + source: hosted | ||
52 | + version: "2.1.1" | ||
53 | + crypto: | ||
54 | + dependency: transitive | ||
55 | + description: | ||
56 | + name: crypto | ||
57 | + url: "https://pub.dartlang.org" | ||
58 | + source: hosted | ||
59 | + version: "2.1.3" | ||
32 | cupertino_icons: | 60 | cupertino_icons: |
33 | dependency: "direct main" | 61 | dependency: "direct main" |
34 | description: | 62 | description: |
35 | name: cupertino_icons | 63 | name: cupertino_icons |
36 | - url: "https://pub.flutter-io.cn" | 64 | + url: "https://pub.dartlang.org" |
37 | source: hosted | 65 | source: hosted |
38 | - version: "0.1.2" | 66 | + version: "0.1.3" |
39 | flutter: | 67 | flutter: |
40 | dependency: "direct main" | 68 | dependency: "direct main" |
41 | description: flutter | 69 | description: flutter |
@@ -47,45 +75,59 @@ packages: | @@ -47,45 +75,59 @@ packages: | ||
47 | path: ".." | 75 | path: ".." |
48 | relative: true | 76 | relative: true |
49 | source: path | 77 | source: path |
50 | - version: "0.7.0" | 78 | + version: "1.0.0" |
51 | flutter_test: | 79 | flutter_test: |
52 | dependency: "direct dev" | 80 | dependency: "direct dev" |
53 | description: flutter | 81 | description: flutter |
54 | source: sdk | 82 | source: sdk |
55 | version: "0.0.0" | 83 | version: "0.0.0" |
84 | + image: | ||
85 | + dependency: transitive | ||
86 | + description: | ||
87 | + name: image | ||
88 | + url: "https://pub.dartlang.org" | ||
89 | + source: hosted | ||
90 | + version: "2.1.4" | ||
56 | matcher: | 91 | matcher: |
57 | dependency: transitive | 92 | dependency: transitive |
58 | description: | 93 | description: |
59 | name: matcher | 94 | name: matcher |
60 | - url: "https://pub.flutter-io.cn" | 95 | + url: "https://pub.dartlang.org" |
61 | source: hosted | 96 | source: hosted |
62 | - version: "0.12.5" | 97 | + version: "0.12.6" |
63 | meta: | 98 | meta: |
64 | dependency: transitive | 99 | dependency: transitive |
65 | description: | 100 | description: |
66 | name: meta | 101 | name: meta |
67 | - url: "https://pub.flutter-io.cn" | 102 | + url: "https://pub.dartlang.org" |
68 | source: hosted | 103 | source: hosted |
69 | - version: "1.1.7" | 104 | + version: "1.1.8" |
70 | path: | 105 | path: |
71 | dependency: transitive | 106 | dependency: transitive |
72 | description: | 107 | description: |
73 | name: path | 108 | name: path |
74 | - url: "https://pub.flutter-io.cn" | 109 | + url: "https://pub.dartlang.org" |
75 | source: hosted | 110 | source: hosted |
76 | version: "1.6.4" | 111 | version: "1.6.4" |
77 | pedantic: | 112 | pedantic: |
78 | dependency: transitive | 113 | dependency: transitive |
79 | description: | 114 | description: |
80 | name: pedantic | 115 | name: pedantic |
81 | - url: "https://pub.flutter-io.cn" | 116 | + url: "https://pub.dartlang.org" |
82 | source: hosted | 117 | source: hosted |
83 | version: "1.8.0+1" | 118 | version: "1.8.0+1" |
119 | + petitparser: | ||
120 | + dependency: transitive | ||
121 | + description: | ||
122 | + name: petitparser | ||
123 | + url: "https://pub.dartlang.org" | ||
124 | + source: hosted | ||
125 | + version: "2.4.0" | ||
84 | quiver: | 126 | quiver: |
85 | dependency: transitive | 127 | dependency: transitive |
86 | description: | 128 | description: |
87 | name: quiver | 129 | name: quiver |
88 | - url: "https://pub.flutter-io.cn" | 130 | + url: "https://pub.dartlang.org" |
89 | source: hosted | 131 | source: hosted |
90 | version: "2.0.5" | 132 | version: "2.0.5" |
91 | sky_engine: | 133 | sky_engine: |
@@ -97,57 +139,64 @@ packages: | @@ -97,57 +139,64 @@ packages: | ||
97 | dependency: transitive | 139 | dependency: transitive |
98 | description: | 140 | description: |
99 | name: source_span | 141 | name: source_span |
100 | - url: "https://pub.flutter-io.cn" | 142 | + url: "https://pub.dartlang.org" |
101 | source: hosted | 143 | source: hosted |
102 | version: "1.5.5" | 144 | version: "1.5.5" |
103 | stack_trace: | 145 | stack_trace: |
104 | dependency: transitive | 146 | dependency: transitive |
105 | description: | 147 | description: |
106 | name: stack_trace | 148 | name: stack_trace |
107 | - url: "https://pub.flutter-io.cn" | 149 | + url: "https://pub.dartlang.org" |
108 | source: hosted | 150 | source: hosted |
109 | version: "1.9.3" | 151 | version: "1.9.3" |
110 | stream_channel: | 152 | stream_channel: |
111 | dependency: transitive | 153 | dependency: transitive |
112 | description: | 154 | description: |
113 | name: stream_channel | 155 | name: stream_channel |
114 | - url: "https://pub.flutter-io.cn" | 156 | + url: "https://pub.dartlang.org" |
115 | source: hosted | 157 | source: hosted |
116 | version: "2.0.0" | 158 | version: "2.0.0" |
117 | string_scanner: | 159 | string_scanner: |
118 | dependency: transitive | 160 | dependency: transitive |
119 | description: | 161 | description: |
120 | name: string_scanner | 162 | name: string_scanner |
121 | - url: "https://pub.flutter-io.cn" | 163 | + url: "https://pub.dartlang.org" |
122 | source: hosted | 164 | source: hosted |
123 | version: "1.0.5" | 165 | version: "1.0.5" |
124 | term_glyph: | 166 | term_glyph: |
125 | dependency: transitive | 167 | dependency: transitive |
126 | description: | 168 | description: |
127 | name: term_glyph | 169 | name: term_glyph |
128 | - url: "https://pub.flutter-io.cn" | 170 | + url: "https://pub.dartlang.org" |
129 | source: hosted | 171 | source: hosted |
130 | version: "1.1.0" | 172 | version: "1.1.0" |
131 | test_api: | 173 | test_api: |
132 | dependency: transitive | 174 | dependency: transitive |
133 | description: | 175 | description: |
134 | name: test_api | 176 | name: test_api |
135 | - url: "https://pub.flutter-io.cn" | 177 | + url: "https://pub.dartlang.org" |
136 | source: hosted | 178 | source: hosted |
137 | - version: "0.2.5" | 179 | + version: "0.2.11" |
138 | typed_data: | 180 | typed_data: |
139 | dependency: transitive | 181 | dependency: transitive |
140 | description: | 182 | description: |
141 | name: typed_data | 183 | name: typed_data |
142 | - url: "https://pub.flutter-io.cn" | 184 | + url: "https://pub.dartlang.org" |
143 | source: hosted | 185 | source: hosted |
144 | version: "1.1.6" | 186 | version: "1.1.6" |
145 | vector_math: | 187 | vector_math: |
146 | dependency: transitive | 188 | dependency: transitive |
147 | description: | 189 | description: |
148 | name: vector_math | 190 | name: vector_math |
149 | - url: "https://pub.flutter-io.cn" | 191 | + url: "https://pub.dartlang.org" |
150 | source: hosted | 192 | source: hosted |
151 | version: "2.0.8" | 193 | version: "2.0.8" |
194 | + xml: | ||
195 | + dependency: transitive | ||
196 | + description: | ||
197 | + name: xml | ||
198 | + url: "https://pub.dartlang.org" | ||
199 | + source: hosted | ||
200 | + version: "3.5.0" | ||
152 | sdks: | 201 | sdks: |
153 | - dart: ">=2.2.2 <3.0.0" | 202 | + dart: ">=2.4.0 <3.0.0" |
@@ -6,12 +6,14 @@ | @@ -6,12 +6,14 @@ | ||
6 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
7 | 7 | ||
8 | class ScreenUtil { | 8 | class ScreenUtil { |
9 | - static ScreenUtil instance = new ScreenUtil(); | 9 | + static ScreenUtil _instance; |
10 | + static const int defaultWidth = 1080; | ||
11 | + static const int defaultHeight = 1920; | ||
10 | 12 | ||
11 | /// UI设计中手机尺寸 , px | 13 | /// UI设计中手机尺寸 , px |
12 | /// Size of the phone in UI Design , px | 14 | /// Size of the phone in UI Design , px |
13 | - double width; | ||
14 | - double height; | 15 | + num uiWidthPx; |
16 | + num uiHeightPx; | ||
15 | 17 | ||
16 | /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 | 18 | /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 |
17 | /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. | 19 | /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. |
@@ -22,22 +24,26 @@ class ScreenUtil { | @@ -22,22 +24,26 @@ class ScreenUtil { | ||
22 | static double _screenHeight; | 24 | static double _screenHeight; |
23 | static double _pixelRatio; | 25 | static double _pixelRatio; |
24 | static double _statusBarHeight; | 26 | static double _statusBarHeight; |
25 | - | ||
26 | static double _bottomBarHeight; | 27 | static double _bottomBarHeight; |
27 | - | ||
28 | static double _textScaleFactor; | 28 | static double _textScaleFactor; |
29 | 29 | ||
30 | - ScreenUtil({ | ||
31 | - this.width = 1080, | ||
32 | - this.height = 1920, | ||
33 | - this.allowFontScaling = false, | ||
34 | - }); | 30 | + ScreenUtil._(); |
35 | 31 | ||
36 | - static ScreenUtil getInstance() { | ||
37 | - return instance; | 32 | + factory ScreenUtil() { |
33 | + return _instance; | ||
38 | } | 34 | } |
39 | 35 | ||
40 | - void init(BuildContext context) { | 36 | + static void init(BuildContext context, |
37 | + {num width = defaultWidth, | ||
38 | + num height = defaultHeight, | ||
39 | + bool allowFontScaling = false}) { | ||
40 | + if (_instance == null) { | ||
41 | + _instance = ScreenUtil._(); | ||
42 | + } | ||
43 | + _instance.uiWidthPx = width; | ||
44 | + _instance.uiHeightPx = height; | ||
45 | + _instance.allowFontScaling = allowFontScaling; | ||
46 | + | ||
41 | MediaQueryData mediaQuery = MediaQuery.of(context); | 47 | MediaQueryData mediaQuery = MediaQuery.of(context); |
42 | _mediaQueryData = mediaQuery; | 48 | _mediaQueryData = mediaQuery; |
43 | _pixelRatio = mediaQuery.devicePixelRatio; | 49 | _pixelRatio = mediaQuery.devicePixelRatio; |
@@ -84,9 +90,11 @@ class ScreenUtil { | @@ -84,9 +90,11 @@ class ScreenUtil { | ||
84 | 90 | ||
85 | /// 实际的dp与UI设计px的比例 | 91 | /// 实际的dp与UI设计px的比例 |
86 | /// The ratio of the actual dp to the design draft px | 92 | /// The ratio of the actual dp to the design draft px |
87 | - double get scaleWidth => _screenWidth / instance.width; | 93 | + double get scaleWidth => _screenWidth / uiWidthPx; |
94 | + | ||
95 | + double get scaleHeight => _screenHeight / uiHeightPx; | ||
88 | 96 | ||
89 | - double get scaleHeight => _screenHeight / instance.height; | 97 | + double get scaleText => scaleWidth > scaleHeight ? scaleWidth : scaleHeight; |
90 | 98 | ||
91 | /// 根据UI设计的设备宽度适配 | 99 | /// 根据UI设计的设备宽度适配 |
92 | /// 高度也可以根据这个来做适配可以保证不变形,比如你先要一个正方形的时候. | 100 | /// 高度也可以根据这个来做适配可以保证不变形,比如你先要一个正方形的时候. |
@@ -110,7 +118,12 @@ class ScreenUtil { | @@ -110,7 +118,12 @@ class ScreenUtil { | ||
110 | ///Font size adaptation method | 118 | ///Font size adaptation method |
111 | ///@param [fontSize] The size of the font on the UI design, in px. | 119 | ///@param [fontSize] The size of the font on the UI design, in px. |
112 | ///@param [allowFontScaling] | 120 | ///@param [allowFontScaling] |
113 | - num setSp(num fontSize) => allowFontScaling | ||
114 | - ? setWidth(fontSize) | ||
115 | - : setWidth(fontSize) / _textScaleFactor; | 121 | + num setSp(num fontSize, {bool allowFontScalingSelf}) => |
122 | + allowFontScalingSelf == null | ||
123 | + ? (allowFontScaling | ||
124 | + ? (fontSize * scaleText) | ||
125 | + : ((fontSize * scaleText) / _textScaleFactor)) | ||
126 | + : (allowFontScalingSelf | ||
127 | + ? (fontSize * scaleText) | ||
128 | + : ((fontSize * scaleText) / _textScaleFactor)); | ||
116 | } | 129 | } |
1 | # Generated by pub | 1 | # Generated by pub |
2 | # See https://dart.dev/tools/pub/glossary#lockfile | 2 | # See https://dart.dev/tools/pub/glossary#lockfile |
3 | packages: | 3 | packages: |
4 | + archive: | ||
5 | + dependency: transitive | ||
6 | + description: | ||
7 | + name: archive | ||
8 | + url: "https://pub.dartlang.org" | ||
9 | + source: hosted | ||
10 | + version: "2.0.11" | ||
11 | + args: | ||
12 | + dependency: transitive | ||
13 | + description: | ||
14 | + name: args | ||
15 | + url: "https://pub.dartlang.org" | ||
16 | + source: hosted | ||
17 | + version: "1.5.2" | ||
4 | async: | 18 | async: |
5 | dependency: transitive | 19 | dependency: transitive |
6 | description: | 20 | description: |
7 | name: async | 21 | name: async |
8 | - url: "https://pub.flutter-io.cn" | 22 | + url: "https://pub.dartlang.org" |
9 | source: hosted | 23 | source: hosted |
10 | - version: "2.3.0" | 24 | + version: "2.4.0" |
11 | boolean_selector: | 25 | boolean_selector: |
12 | dependency: transitive | 26 | dependency: transitive |
13 | description: | 27 | description: |
14 | name: boolean_selector | 28 | name: boolean_selector |
15 | - url: "https://pub.flutter-io.cn" | 29 | + url: "https://pub.dartlang.org" |
16 | source: hosted | 30 | source: hosted |
17 | version: "1.0.5" | 31 | version: "1.0.5" |
18 | charcode: | 32 | charcode: |
19 | dependency: transitive | 33 | dependency: transitive |
20 | description: | 34 | description: |
21 | name: charcode | 35 | name: charcode |
22 | - url: "https://pub.flutter-io.cn" | 36 | + url: "https://pub.dartlang.org" |
23 | source: hosted | 37 | source: hosted |
24 | version: "1.1.2" | 38 | version: "1.1.2" |
25 | collection: | 39 | collection: |
26 | dependency: transitive | 40 | dependency: transitive |
27 | description: | 41 | description: |
28 | name: collection | 42 | name: collection |
29 | - url: "https://pub.flutter-io.cn" | 43 | + url: "https://pub.dartlang.org" |
30 | source: hosted | 44 | source: hosted |
31 | version: "1.14.11" | 45 | version: "1.14.11" |
46 | + convert: | ||
47 | + dependency: transitive | ||
48 | + description: | ||
49 | + name: convert | ||
50 | + url: "https://pub.dartlang.org" | ||
51 | + source: hosted | ||
52 | + version: "2.1.1" | ||
53 | + crypto: | ||
54 | + dependency: transitive | ||
55 | + description: | ||
56 | + name: crypto | ||
57 | + url: "https://pub.dartlang.org" | ||
58 | + source: hosted | ||
59 | + version: "2.1.3" | ||
32 | flutter: | 60 | flutter: |
33 | dependency: "direct main" | 61 | dependency: "direct main" |
34 | description: flutter | 62 | description: flutter |
@@ -39,39 +67,53 @@ packages: | @@ -39,39 +67,53 @@ packages: | ||
39 | description: flutter | 67 | description: flutter |
40 | source: sdk | 68 | source: sdk |
41 | version: "0.0.0" | 69 | version: "0.0.0" |
70 | + image: | ||
71 | + dependency: transitive | ||
72 | + description: | ||
73 | + name: image | ||
74 | + url: "https://pub.dartlang.org" | ||
75 | + source: hosted | ||
76 | + version: "2.1.4" | ||
42 | matcher: | 77 | matcher: |
43 | dependency: transitive | 78 | dependency: transitive |
44 | description: | 79 | description: |
45 | name: matcher | 80 | name: matcher |
46 | - url: "https://pub.flutter-io.cn" | 81 | + url: "https://pub.dartlang.org" |
47 | source: hosted | 82 | source: hosted |
48 | - version: "0.12.5" | 83 | + version: "0.12.6" |
49 | meta: | 84 | meta: |
50 | dependency: transitive | 85 | dependency: transitive |
51 | description: | 86 | description: |
52 | name: meta | 87 | name: meta |
53 | - url: "https://pub.flutter-io.cn" | 88 | + url: "https://pub.dartlang.org" |
54 | source: hosted | 89 | source: hosted |
55 | - version: "1.1.7" | 90 | + version: "1.1.8" |
56 | path: | 91 | path: |
57 | dependency: transitive | 92 | dependency: transitive |
58 | description: | 93 | description: |
59 | name: path | 94 | name: path |
60 | - url: "https://pub.flutter-io.cn" | 95 | + url: "https://pub.dartlang.org" |
61 | source: hosted | 96 | source: hosted |
62 | version: "1.6.4" | 97 | version: "1.6.4" |
63 | pedantic: | 98 | pedantic: |
64 | dependency: transitive | 99 | dependency: transitive |
65 | description: | 100 | description: |
66 | name: pedantic | 101 | name: pedantic |
67 | - url: "https://pub.flutter-io.cn" | 102 | + url: "https://pub.dartlang.org" |
68 | source: hosted | 103 | source: hosted |
69 | version: "1.8.0+1" | 104 | version: "1.8.0+1" |
105 | + petitparser: | ||
106 | + dependency: transitive | ||
107 | + description: | ||
108 | + name: petitparser | ||
109 | + url: "https://pub.dartlang.org" | ||
110 | + source: hosted | ||
111 | + version: "2.4.0" | ||
70 | quiver: | 112 | quiver: |
71 | dependency: transitive | 113 | dependency: transitive |
72 | description: | 114 | description: |
73 | name: quiver | 115 | name: quiver |
74 | - url: "https://pub.flutter-io.cn" | 116 | + url: "https://pub.dartlang.org" |
75 | source: hosted | 117 | source: hosted |
76 | version: "2.0.5" | 118 | version: "2.0.5" |
77 | sky_engine: | 119 | sky_engine: |
@@ -83,57 +125,64 @@ packages: | @@ -83,57 +125,64 @@ packages: | ||
83 | dependency: transitive | 125 | dependency: transitive |
84 | description: | 126 | description: |
85 | name: source_span | 127 | name: source_span |
86 | - url: "https://pub.flutter-io.cn" | 128 | + url: "https://pub.dartlang.org" |
87 | source: hosted | 129 | source: hosted |
88 | version: "1.5.5" | 130 | version: "1.5.5" |
89 | stack_trace: | 131 | stack_trace: |
90 | dependency: transitive | 132 | dependency: transitive |
91 | description: | 133 | description: |
92 | name: stack_trace | 134 | name: stack_trace |
93 | - url: "https://pub.flutter-io.cn" | 135 | + url: "https://pub.dartlang.org" |
94 | source: hosted | 136 | source: hosted |
95 | version: "1.9.3" | 137 | version: "1.9.3" |
96 | stream_channel: | 138 | stream_channel: |
97 | dependency: transitive | 139 | dependency: transitive |
98 | description: | 140 | description: |
99 | name: stream_channel | 141 | name: stream_channel |
100 | - url: "https://pub.flutter-io.cn" | 142 | + url: "https://pub.dartlang.org" |
101 | source: hosted | 143 | source: hosted |
102 | version: "2.0.0" | 144 | version: "2.0.0" |
103 | string_scanner: | 145 | string_scanner: |
104 | dependency: transitive | 146 | dependency: transitive |
105 | description: | 147 | description: |
106 | name: string_scanner | 148 | name: string_scanner |
107 | - url: "https://pub.flutter-io.cn" | 149 | + url: "https://pub.dartlang.org" |
108 | source: hosted | 150 | source: hosted |
109 | version: "1.0.5" | 151 | version: "1.0.5" |
110 | term_glyph: | 152 | term_glyph: |
111 | dependency: transitive | 153 | dependency: transitive |
112 | description: | 154 | description: |
113 | name: term_glyph | 155 | name: term_glyph |
114 | - url: "https://pub.flutter-io.cn" | 156 | + url: "https://pub.dartlang.org" |
115 | source: hosted | 157 | source: hosted |
116 | version: "1.1.0" | 158 | version: "1.1.0" |
117 | test_api: | 159 | test_api: |
118 | dependency: transitive | 160 | dependency: transitive |
119 | description: | 161 | description: |
120 | name: test_api | 162 | name: test_api |
121 | - url: "https://pub.flutter-io.cn" | 163 | + url: "https://pub.dartlang.org" |
122 | source: hosted | 164 | source: hosted |
123 | - version: "0.2.5" | 165 | + version: "0.2.11" |
124 | typed_data: | 166 | typed_data: |
125 | dependency: transitive | 167 | dependency: transitive |
126 | description: | 168 | description: |
127 | name: typed_data | 169 | name: typed_data |
128 | - url: "https://pub.flutter-io.cn" | 170 | + url: "https://pub.dartlang.org" |
129 | source: hosted | 171 | source: hosted |
130 | version: "1.1.6" | 172 | version: "1.1.6" |
131 | vector_math: | 173 | vector_math: |
132 | dependency: transitive | 174 | dependency: transitive |
133 | description: | 175 | description: |
134 | name: vector_math | 176 | name: vector_math |
135 | - url: "https://pub.flutter-io.cn" | 177 | + url: "https://pub.dartlang.org" |
136 | source: hosted | 178 | source: hosted |
137 | version: "2.0.8" | 179 | version: "2.0.8" |
180 | + xml: | ||
181 | + dependency: transitive | ||
182 | + description: | ||
183 | + name: xml | ||
184 | + url: "https://pub.dartlang.org" | ||
185 | + source: hosted | ||
186 | + version: "3.5.0" | ||
138 | sdks: | 187 | sdks: |
139 | - dart: ">=2.2.2 <3.0.0" | 188 | + dart: ">=2.4.0 <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.7.0 | 3 | +version: 1.0.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