kageeker
@@ -19,5 +19,4 @@ doc @@ -19,5 +19,4 @@ doc
19 # Include when developing application packages. 19 # Include when developing application packages.
20 .lock 20 .lock
21 coverage* 21 coverage*
22 -*.iml  
23 *.lock 22 *.lock
  1 +# 5.1.1
  2 +- .w,.h use MediaQuery
  3 +
  4 +# 5.1.0
  5 +- Break Change: updated the first initialization method, please refer to README.md
  6 +
  7 +# 5.0.4
  8 +- Break Change : add setContext() , the first initialization method requires calling
  9 +- fix # 310
  10 +- update ReadMe.md
  11 +
  12 +# 5.0.3
  13 +
  14 +- init method add "context" param
  15 +- update ReadMe.md
  16 +
  17 +# 5.0.2+1
  18 +
  19 +- fix splitScreenMode to false
  20 +
  21 +# 5.0.2
  22 +
  23 +- add "minTextAdapt" param , Font adaptation is based on the minimum value of width and height or
  24 + only based on width(default)
  25 +- update readme
  26 +
  27 +# 5.0.1+3
  28 +
  29 +- fix .r
  30 +
  31 +# 5.0.1+2
  32 +
  33 +- Text adaptation no longer considers the height of the screen
  34 +
  35 +# 5.0.1+1
  36 +
  37 +- split default value change to false
  38 +
  39 +# 5.0.1
  40 +
  41 +- support for split screen
  42 +- add number.sm (return min(number.sp , number))
  43 +
1 # 5.0.0+2 44 # 5.0.0+2
  45 +
2 - update readme 46 - update readme
3 47
4 # 5.0.0+1 48 # 5.0.0+1
  49 +
5 - update readme 50 - update readme
6 51
7 # 5.0.0 52 # 5.0.0
8 --Breaking change. Use a new way to set font scaling  
9 --Deprecated ssp and nsp 53 +
  54 +-Breaking change. Use a new way to set font scaling -Deprecated ssp and nsp
10 55
11 # 5.0.0-nullsafety.11 56 # 5.0.0-nullsafety.11
  57 +
12 - revert 5.0.0-nullsafety.10 58 - revert 5.0.0-nullsafety.10
13 - fix #230 59 - fix #230
14 60
15 # 5.0.0-nullsafety.10 61 # 5.0.0-nullsafety.10
  62 +
16 - fix #228 63 - fix #228
17 64
18 # 5.0.0-nullsafety.9 65 # 5.0.0-nullsafety.9
  66 +
19 - Supplementary documentation, supports two initialization methods 67 - Supplementary documentation, supports two initialization methods
20 68
21 # 5.0.0-nullsafety.8 69 # 5.0.0-nullsafety.8
  70 +
22 - merge v4 71 - merge v4
23 - Add a method to get the screen orientation 72 - Add a method to get the screen orientation
24 73
25 # 5.0.0-nullsafety.7 74 # 5.0.0-nullsafety.7
  75 +
26 - fix #221 76 - fix #221
27 77
28 # 5.0.0-nullsafety.6 78 # 5.0.0-nullsafety.6
  79 +
29 - merge #216 #218 80 - merge #216 #218
30 81
31 # 5.0.0-nullsafety.5 82 # 5.0.0-nullsafety.5
  83 +
32 - Optimize initialization method 84 - Optimize initialization method
33 85
34 # 5.0.0-nullsafety.4 86 # 5.0.0-nullsafety.4
  87 +
35 - merge #205 88 - merge #205
36 89
37 # 5.0.0-nullsafety.3 90 # 5.0.0-nullsafety.3
  91 +
38 - merge 4.0.2+3 92 - merge 4.0.2+3
39 93
40 # 5.0.0-nullsafety.2 94 # 5.0.0-nullsafety.2
  95 +
41 - merge 4.0.2+2 #186 96 - merge 4.0.2+2 #186
42 97
43 # 5.0.0-nullsafety.1 98 # 5.0.0-nullsafety.1
  99 +
44 - merge 4.0.1 ,4.0.2 #183 100 - merge 4.0.1 ,4.0.2 #183
45 101
46 # 5.0.0-nullsafety.0 102 # 5.0.0-nullsafety.0
  103 +
47 - Migrated flutter_screenutil to non-nullable 104 - Migrated flutter_screenutil to non-nullable
48 105
49 # 4.0.2 106 # 4.0.2
  107 +
50 - add r(),adapt according to the smaller of width or height 108 - add r(),adapt according to the smaller of width or height
51 109
52 # 4.0.1 110 # 4.0.1
  111 +
53 - Modify the initialization unit to dp 112 - Modify the initialization unit to dp
54 - delete screenWidthPx and screenHeightPx(No one use these method,I guess) 113 - delete screenWidthPx and screenHeightPx(No one use these method,I guess)
55 114
56 # 4.0.0 115 # 4.0.0
  116 +
57 - update to 4.0.0 117 - update to 4.0.0
58 118
59 # 4.0.0-beta3 119 # 4.0.0-beta3
  120 +
60 - Optimize the way of initialization 121 - Optimize the way of initialization
61 122
62 # 4.0.0-beta2 123 # 4.0.0-beta2
  124 +
63 - fix error:'window is not a type.' 125 - fix error:'window is not a type.'
64 126
65 # 4.0.0-beta1 127 # 4.0.0-beta1
  128 +
66 - change readme 129 - change readme
67 130
68 # 4.0.0-beta 131 # 4.0.0-beta
  132 +
69 - Modified the initialization method 133 - Modified the initialization method
70 - Support font adaptation in themedata 134 - Support font adaptation in themedata
71 135
72 # 3.2.0 136 # 3.2.0
  137 +
73 - Modify the method name to be more semantic: wp->sw , hp->sh 138 - Modify the method name to be more semantic: wp->sw , hp->sh
74 - Remove the restriction of flutter version 139 - Remove the restriction of flutter version
75 - Modify the return type num to double 140 - Modify the return type num to double
76 141
77 # 3.1.1 142 # 3.1.1
  143 +
78 - change readme 144 - change readme
79 145
80 # 3.1.0 146 # 3.1.0
  147 +
81 - Use the way back to v2 version 148 - Use the way back to v2 version
82 - Modify registration method 149 - Modify registration method
83 150
84 # 3.0.2+1 151 # 3.0.2+1
  152 +
85 - Guide users to use V2 version 153 - Guide users to use V2 version
86 154
87 # 3.0.2 155 # 3.0.2
  156 +
88 - Change the unit of'statusBarHeight' and 'bottomBarHeight' to dp 157 - Change the unit of'statusBarHeight' and 'bottomBarHeight' to dp
89 158
90 # 3.0.1 159 # 3.0.1
  160 +
91 - update readme 161 - update readme
92 162
93 # 3.0.0 163 # 3.0.0
  164 +
94 - After a period of experimentation, I think it's time to release the official version 165 - After a period of experimentation, I think it's time to release the official version
95 166
96 # 3.0.0-beta.2 167 # 3.0.0-beta.2
  168 +
97 - readme update 169 - readme update
98 170
99 # 3.0.0-beta.1 171 # 3.0.0-beta.1
  172 +
100 **BREAKING CHANGES** 173 **BREAKING CHANGES**
  174 +
101 - `BuildContext` is no more required while initializing. i.e. ScreenUtil.init(~~context~~) 175 - `BuildContext` is no more required while initializing. i.e. ScreenUtil.init(~~context~~)
102 - Initialize size of design draft using `designSize` instead of width & height. 176 - Initialize size of design draft using `designSize` instead of width & height.
103 - All the static methods are now member methods. 177 - All the static methods are now member methods.
104 178
105 # 2.3.1 179 # 2.3.1
  180 +
106 - add textStyle Example. 181 - add textStyle Example.
107 182
108 # 2.3.0 183 # 2.3.0
  184 +
109 - We still need context to initialize, sorry. 185 - We still need context to initialize, sorry.
110 186
111 # 2.2.0 187 # 2.2.0
  188 +
112 - add 'wp','hp'. Get the height/width of the screen proportionally 189 - add 'wp','hp'. Get the height/width of the screen proportionally
113 - For example: 0.5.wp : Half the width of the screen. 190 - For example: 0.5.wp : Half the width of the screen.
114 191
115 # 2.1.0 192 # 2.1.0
116 -- add 'nsp' , you can use 'fontSize: 24.nsp' instead of 'fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: false)' 193 +
  194 +- add 'nsp' , you can use 'fontSize: 24.nsp' instead of 'fontSize: ScreenUtil().setSp(24,
  195 + allowFontScalingSelf: false)'
117 196
118 # 2.0.0 197 # 2.0.0
119 -- Use `MediaQueryData.fromWindow(window)` instead of `MediaQuery.of(context)`, no context parameter required 198 +
  199 +- Use `MediaQueryData.fromWindow(window)` instead of `MediaQuery.of(context)`, no context parameter
  200 + required
120 - API changes, please note 201 - API changes, please note
121 202
122 # 1.1.0 203 # 1.1.0
  204 +
123 - support ExtensionMethod Dart-SDK-2.6.0 205 - support ExtensionMethod Dart-SDK-2.6.0
124 - you can use 'width: 50.w' instead of 'width: ScreenUtil().setWidth(50)' 206 - you can use 'width: 50.w' instead of 'width: ScreenUtil().setWidth(50)'
125 '50.h' instead of 'ScreenUtil().setHeight(50)' 207 '50.h' instead of 'ScreenUtil().setHeight(50)'
@@ -127,18 +209,20 @@ @@ -127,18 +209,20 @@
127 '24.ssp' instead of 'ScreenUtil().setSp(24, allowFontScalingSelf: true)' 209 '24.ssp' instead of 'ScreenUtil().setSp(24, allowFontScalingSelf: true)'
128 210
129 # 1.0.2 211 # 1.0.2
  212 +
130 - fix #89 213 - fix #89
131 - 优化屏幕旋转效果 214 - 优化屏幕旋转效果
132 - 字体适配统一使用宽度 215 - 字体适配统一使用宽度
133 216
134 # 1.0.1 217 # 1.0.1
135 -- Rebuild code, change API  
136 - Delete "getInstance()", please use "ScreenUtil ()" instead of "ScreenUtil.getInstance()"  
137 - use "ScreenUtil().setSp(24, allowFontScalingSelf: true)" instead of "ScreenUtil.getInstance().setSp(14, true)" 218 +
  219 +- Rebuild code, change API Delete "getInstance()", please use "ScreenUtil ()" instead of "
  220 + ScreenUtil.getInstance()"
  221 + use "ScreenUtil().setSp(24, allowFontScalingSelf: true)" instead of "ScreenUtil.getInstance()
  222 + .setSp(14, true)"
138 - Modify the initialization method 223 - Modify the initialization method
139 - Fix #68 224 - Fix #68
140 -- Change example code  
141 - Example CompileSdkVersion change to 28 225 +- Change example code Example CompileSdkVersion change to 28
142 226
143 **If there is significant impact, please return to 0.7.0** 227 **If there is significant impact, please return to 0.7.0**
144 228
@@ -170,7 +254,8 @@ @@ -170,7 +254,8 @@
170 254
171 - Fix the wrong way of using 255 - Fix the wrong way of using
172 256
173 -- It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)` 257 +- It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` , for
  258 + example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)`
174 259
175 # 0.4.4 260 # 0.4.4
176 261
@@ -180,9 +265,9 @@ @@ -180,9 +265,9 @@
180 265
181 - Modify the font to change with the system zoom mode. The default value is false. 266 - Modify the font to change with the system zoom mode. The default value is false.
182 267
183 -- setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling  
184 -? setWidth(fontSize) \* \_textScaleFactor  
185 -: setWidth(fontSize); 268 +- setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling ? setWidth(fontSize) \*
  269 + \_textScaleFactor
  270 + : setWidth(fontSize);
186 271
187 # 0.4.2 272 # 0.4.2
188 273
@@ -206,9 +291,10 @@ @@ -206,9 +291,10 @@
206 # 0.3.1 291 # 0.3.1
207 292
208 - Perfect documentation 293 - Perfect documentation
209 -- Width is enlarged relative to the design draft => The ratio of font and width to the size of the design  
210 -- Height is enlarged relative to the design draft => The ratio of height width to the size of the design  
211 - 294 +- Width is enlarged relative to the design draft => The ratio of font and width to the size of the
  295 + design
  296 +- Height is enlarged relative to the design draft => The ratio of height width to the size of the
  297 + design
212 298
213 # 0.3.0 299 # 0.3.0
214 300
1 # flutter_screenutil 1 # flutter_screenutil
2 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dev/packages/flutter_screenutil) 2 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dev/packages/flutter_screenutil)
  3 +[![pub points](https://badges.bar/flutter_screenutil/pub%20points)](https://pub.dev/packages/flutter_screenutil/score)
  4 +[![popularity](https://badges.bar/flutter_screenutil/popularity)](https://pub.dev/packages/flutter_screenutil/score)
3 5
4 **A flutter plugin for adapting screen and font size.Let your UI display a reasonable layout on different screen sizes!** 6 **A flutter plugin for adapting screen and font size.Let your UI display a reasonable layout on different screen sizes!**
5 7
@@ -56,6 +58,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -56,6 +58,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
56 <td>portrait</td> 58 <td>portrait</td>
57 <td>screen orientation</td> 59 <td>screen orientation</td>
58 </tr> 60 </tr>
  61 + <tr>
  62 + <td>splitScreenMode</td>
  63 + <td>bool</td>
  64 + <td>true</td>
  65 + <td>support for split screen</td>
  66 + </tr>
  67 + <tr>
  68 + <td>minTextAdapt</td>
  69 + <td>bool</td>
  70 + <td>false</td>
  71 + <td>Whether to adapt the text according to the minimum of width and height</td>
  72 + </tr>
  73 + <tr>
  74 + <td>context</td>
  75 + <td>BuildContext</td>
  76 + <td>null</td>
  77 + <td>If context!=null, screen changes will be more sensitive</td>
  78 + </tr>
59 </table> 79 </table>
60 80
61 ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option 81 ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option
@@ -71,10 +91,21 @@ class MyApp extends StatelessWidget { @@ -71,10 +91,21 @@ class MyApp extends StatelessWidget {
71 //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) 91 //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
72 return ScreenUtilInit( 92 return ScreenUtilInit(
73 designSize: Size(360, 690), 93 designSize: Size(360, 690),
74 - builder: () => MaterialApp(  
75 - ... 94 + minTextAdapt: true,
  95 + splitScreenMode: true,
  96 + builder: () =>
  97 + MaterialApp(
  98 + //... other code
  99 + builder: (context, widget) {
  100 + //add this line
  101 + ScreenUtil.setContext(context);
  102 + return MediaQuery(
  103 + //Setting font does not change with system font size
  104 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  105 + child: widget!,
  106 + );
  107 + },
76 theme: ThemeData( 108 theme: ThemeData(
77 - primarySwatch: Colors.blue,  
78 textTheme: TextTheme( 109 textTheme: TextTheme(
79 //To support the following, you need to use the first initialization method 110 //To support the following, you need to use the first initialization method
80 button: TextStyle(fontSize: 45.sp) 111 button: TextStyle(fontSize: 45.sp)
@@ -135,6 +166,8 @@ class _HomePageState extends State<HomePage> { @@ -135,6 +166,8 @@ class _HomePageState extends State<HomePage> {
135 maxWidth: MediaQuery.of(context).size.width, 166 maxWidth: MediaQuery.of(context).size.width,
136 maxHeight: MediaQuery.of(context).size.height), 167 maxHeight: MediaQuery.of(context).size.height),
137 designSize: Size(360, 690), 168 designSize: Size(360, 690),
  169 + context: context,
  170 + minTextAdapt: true,
138 orientation: Orientation.portrait); 171 orientation: Orientation.portrait);
139 return Scaffold(); 172 return Scaffold();
140 } 173 }
@@ -152,6 +185,7 @@ class _HomePageState extends State<HomePage> { @@ -152,6 +185,7 @@ class _HomePageState extends State<HomePage> {
152 ScreenUtil().setHeight(200) (dart sdk>=2.6 : 200.h) //Adapted to screen height , under normal circumstances, the height still uses x.w 185 ScreenUtil().setHeight(200) (dart sdk>=2.6 : 200.h) //Adapted to screen height , under normal circumstances, the height still uses x.w
153 ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height 186 ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height
154 ScreenUtil().setSp(24) (dart sdk>=2.6 : 24.sp) //Adapter font 187 ScreenUtil().setSp(24) (dart sdk>=2.6 : 24.sp) //Adapter font
  188 + 12.sm //return min(12,12.sp)
155 189
156 ScreenUtil().pixelRatio //Device pixel density 190 ScreenUtil().pixelRatio //Device pixel density
157 ScreenUtil().screenWidth (dart sdk>=2.6 : 1.sw) //Device width 191 ScreenUtil().screenWidth (dart sdk>=2.6 : 1.sw) //Device width
1 -# flutter_screenUtil 1 +# flutter_screenutil
2 2
3 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil) 3 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil)
  4 +[![pub points](https://badges.bar/flutter_screenutil/pub%20points)](https://pub.dev/packages/flutter_screenutil/score)
  5 +[![popularity](https://badges.bar/flutter_screenutil/popularity)](https://pub.dev/packages/flutter_screenutil/score)
4 6
5 **flutter 屏幕适配方案,让你的UI在不同尺寸的屏幕上都能显示合理的布局!** 7 **flutter 屏幕适配方案,让你的UI在不同尺寸的屏幕上都能显示合理的布局!**
6 8
@@ -42,6 +44,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -42,6 +44,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
42 |designSize|Size|Size(360, 690)|设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)| 44 |designSize|Size|Size(360, 690)|设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)|
43 |builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()| 45 |builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()|
44 |orientation|Orientation|portrait|屏幕方向| 46 |orientation|Orientation|portrait|屏幕方向|
  47 +|splitScreenMode|bool|true|支持分屏尺寸|
  48 +|minTextAdapt|bool|false|是否根据宽度/高度中的最小值适配文字|
  49 +|context|BuildContext|null|传入context会更灵敏的根据屏幕变化而改变|
45 50
46 ### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放 51 ### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
47 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致) 52 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致)
@@ -57,17 +62,26 @@ class MyApp extends StatelessWidget { @@ -57,17 +62,26 @@ class MyApp extends StatelessWidget {
57 //填入设计稿中设备的屏幕尺寸,单位dp 62 //填入设计稿中设备的屏幕尺寸,单位dp
58 return ScreenUtilInit( 63 return ScreenUtilInit(
59 designSize: Size(360, 690), 64 designSize: Size(360, 690),
60 - builder: () => MaterialApp(  
61 - debugShowCheckedModeBanner: false,  
62 - title: 'Flutter_ScreenUtil', 65 + minTextAdapt: true,
  66 + splitScreenMode: true,
  67 + builder: () =>
  68 + MaterialApp(
  69 + //... other code
  70 + builder: (context, widget) {
  71 + //add this line
  72 + ScreenUtil.setContext(context);
  73 + return MediaQuery(
  74 + //Setting font does not change with system font size
  75 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  76 + child: widget!,
  77 + );
  78 + },
63 theme: ThemeData( 79 theme: ThemeData(
64 - primarySwatch: Colors.blue,  
65 - //要支持下面这个需要使用第一种初始化方式  
66 textTheme: TextTheme( 80 textTheme: TextTheme(
  81 + //要支持下面这个需要使用第一种初始化方式
67 button: TextStyle(fontSize: 45.sp) 82 button: TextStyle(fontSize: 45.sp)
68 ), 83 ),
69 ), 84 ),
70 - home: HomePage(title: 'FlutterScreenUtil Demo'),  
71 ), 85 ),
72 ); 86 );
73 } 87 }
@@ -112,6 +126,8 @@ class _HomePageState extends State<HomePage> { @@ -112,6 +126,8 @@ class _HomePageState extends State<HomePage> {
112 maxWidth: MediaQuery.of(context).size.width, 126 maxWidth: MediaQuery.of(context).size.width,
113 maxHeight: MediaQuery.of(context).size.height), 127 maxHeight: MediaQuery.of(context).size.height),
114 designSize: Size(360, 690), 128 designSize: Size(360, 690),
  129 + context: context,
  130 + minTextAdapt: true,
115 orientation: Orientation.portrait); 131 orientation: Orientation.portrait);
116 return Scaffold(); 132 return Scaffold();
117 } 133 }
@@ -127,6 +143,7 @@ class _HomePageState extends State<HomePage> { @@ -127,6 +143,7 @@ class _HomePageState extends State<HomePage> {
127 ScreenUtil().setHeight(200) (sdk>=2.6 : 200.h) //根据屏幕高度适配尺寸(一般根据宽度适配即可) 143 ScreenUtil().setHeight(200) (sdk>=2.6 : 200.h) //根据屏幕高度适配尺寸(一般根据宽度适配即可)
128 ScreenUtil().radius(200) (sdk>=2.6 : 200.r) //根据宽度或高度中的较小者进行调整 144 ScreenUtil().radius(200) (sdk>=2.6 : 200.r) //根据宽度或高度中的较小者进行调整
129 ScreenUtil().setSp(24) (sdk>=2.6 : 24.sp) //适配字体 145 ScreenUtil().setSp(24) (sdk>=2.6 : 24.sp) //适配字体
  146 + 12.sm // 取12和12.sp中的最小值
130 147
131 ScreenUtil.pixelRatio //设备的像素密度 148 ScreenUtil.pixelRatio //设备的像素密度
132 ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度 149 ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度
1 # I don’t speak Portuguese, and other developers have translated the first version. I later modified it based on the translation software. It is recommended to read the English/Chinese version. 1 # I don’t speak Portuguese, and other developers have translated the first version. I later modified it based on the translation software. It is recommended to read the English/Chinese version.
2 # flutter_screenutil 2 # flutter_screenutil
3 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil) 3 [![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil)
  4 +[![pub points](https://badges.bar/flutter_screenutil/pub%20points)](https://pub.dev/packages/flutter_screenutil/score)
  5 +[![popularity](https://badges.bar/flutter_screenutil/popularity)](https://pub.dev/packages/flutter_screenutil/score)
4 6
5 **Um plugin Flutter para adaptação de tamanho de tela e fontes. Deixe sua UI exibir um layout aceitável em diferentes tamanhos de tela!** 7 **Um plugin Flutter para adaptação de tamanho de tela e fontes. Deixe sua UI exibir um layout aceitável em diferentes tamanhos de tela!**
6 8
@@ -39,6 +41,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -39,6 +41,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
39 |designSize|Size|Size(360, 690)|The size of the device screen in the design draft, in dp| 41 |designSize|Size|Size(360, 690)|The size of the device screen in the design draft, in dp|
40 |builder|Widget Function()|Container()|Generally returning a Function of MaterialApp type| 42 |builder|Widget Function()|Container()|Generally returning a Function of MaterialApp type|
41 |orientation|Orientation|portrait|screen orientation| 43 |orientation|Orientation|portrait|screen orientation|
  44 +|minTextAdapt|bool|false|Whether to adapt the text according to the minimum of width and height|
  45 +|context|BuildContext|null|传入context会更灵敏的根据屏幕变化而改变|
42 46
43 ### Inicialize e defina o tamanho de ajuste e tamanho da fonte para dimensionar de acordo com a opção "tamanho de fonte" na acessibilidade do sistema 47 ### Inicialize e defina o tamanho de ajuste e tamanho da fonte para dimensionar de acordo com a opção "tamanho de fonte" na acessibilidade do sistema
44 Por favor, defina a largura e altura do protótipo de design antes de usar (em pixels). 48 Por favor, defina a largura e altura do protótipo de design antes de usar (em pixels).
@@ -54,12 +58,23 @@ class MyApp extends StatelessWidget { @@ -54,12 +58,23 @@ class MyApp extends StatelessWidget {
54 //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) 58 //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
55 return ScreenUtilInit( 59 return ScreenUtilInit(
56 designSize: Size(360, 690), 60 designSize: Size(360, 690),
57 - builder: () => MaterialApp(  
58 - ... 61 + minTextAdapt: true,
  62 + splitScreenMode: true,
  63 + builder: () =>
  64 + MaterialApp(
  65 + //... other code
  66 + builder: (context, widget) {
  67 + //add this line
  68 + ScreenUtil.setContext(context);
  69 + return MediaQuery(
  70 + //Setting font does not change with system font size
  71 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  72 + child: widget!,
  73 + );
  74 + },
59 theme: ThemeData( 75 theme: ThemeData(
60 - primarySwatch: Colors.blue,  
61 - //To support the following, you need to use the first initialization method  
62 textTheme: TextTheme( 76 textTheme: TextTheme(
  77 + //To support the following, you need to use the first initialization method
63 button: TextStyle(fontSize: 45.sp) 78 button: TextStyle(fontSize: 45.sp)
64 ), 79 ),
65 ), 80 ),
@@ -103,6 +118,7 @@ class _HomePageState extends State<HomePage> { @@ -103,6 +118,7 @@ class _HomePageState extends State<HomePage> {
103 maxWidth: MediaQuery.of(context).size.width, 118 maxWidth: MediaQuery.of(context).size.width,
104 maxHeight: MediaQuery.of(context).size.height), 119 maxHeight: MediaQuery.of(context).size.height),
105 designSize: Size(360, 690), 120 designSize: Size(360, 690),
  121 + context: context,
106 orientation: Orientation.portrait); 122 orientation: Orientation.portrait);
107 return Scaffold(); 123 return Scaffold();
108 } 124 }
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<module type="JAVA_MODULE" version="4">
  3 + <component name="FacetManager">
  4 + <facet type="android" name="Android">
  5 + <configuration>
  6 + <option name="ALLOW_USER_CONFIGURATION" value="false" />
  7 + <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
  8 + <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
  9 + <option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" />
  10 + <option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" />
  11 + <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" />
  12 + <option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" />
  13 + <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" />
  14 + </configuration>
  15 + </facet>
  16 + </component>
  17 + <component name="NewModuleRootManager" inherit-compiler-output="true">
  18 + <exclude-output />
  19 + <content url="file://$MODULE_DIR$">
  20 + <sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
  21 + <sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" />
  22 + <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
  23 + </content>
  24 + <orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
  25 + <orderEntry type="sourceFolder" forTests="false" />
  26 + <orderEntry type="library" name="Flutter for Android" level="project" />
  27 + <orderEntry type="library" name="KotlinJavaRuntime" level="project" />
  28 + </component>
  29 +</module>
@@ -21,6 +21,6 @@ @@ -21,6 +21,6 @@
21 <key>CFBundleVersion</key> 21 <key>CFBundleVersion</key>
22 <string>1.0</string> 22 <string>1.0</string>
23 <key>MinimumOSVersion</key> 23 <key>MinimumOSVersion</key>
24 - <string>8.0</string> 24 + <string>9.0</string>
25 </dict> 25 </dict>
26 </plist> 26 </plist>
@@ -3,11 +3,16 @@ @@ -3,11 +3,16 @@
3 export "FLUTTER_ROOT=C:\dev\flutter" 3 export "FLUTTER_ROOT=C:\dev\flutter"
4 export "FLUTTER_APPLICATION_PATH=C:\Users\kagee\Documents\flutter_screenutil\example" 4 export "FLUTTER_APPLICATION_PATH=C:\Users\kagee\Documents\flutter_screenutil\example"
5 export "COCOAPODS_PARALLEL_CODE_SIGN=true" 5 export "COCOAPODS_PARALLEL_CODE_SIGN=true"
  6 +<<<<<<< HEAD
6 export "FLUTTER_TARGET=lib\main.dart" 7 export "FLUTTER_TARGET=lib\main.dart"
  8 +=======
  9 +export "FLUTTER_TARGET=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/lib/main.dart"
  10 +>>>>>>> 30a18a0ab24cfbb7f41bc5abd3b88e91b091d595
7 export "FLUTTER_BUILD_DIR=build" 11 export "FLUTTER_BUILD_DIR=build"
8 export "FLUTTER_BUILD_NAME=1.0.0" 12 export "FLUTTER_BUILD_NAME=1.0.0"
9 export "FLUTTER_BUILD_NUMBER=1" 13 export "FLUTTER_BUILD_NUMBER=1"
  14 +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
10 export "DART_OBFUSCATION=false" 15 export "DART_OBFUSCATION=false"
11 -export "TRACK_WIDGET_CREATION=false" 16 +export "TRACK_WIDGET_CREATION=true"
12 export "TREE_SHAKE_ICONS=false" 17 export "TREE_SHAKE_ICONS=false"
13 -export "PACKAGE_CONFIG=.packages" 18 +export "PACKAGE_CONFIG=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json"
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 archiveVersion = 1; 3 archiveVersion = 1;
4 classes = { 4 classes = {
5 }; 5 };
6 - objectVersion = 46; 6 + objectVersion = 50;
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
@@ -139,7 +139,7 @@ @@ -139,7 +139,7 @@
139 97C146E61CF9000F007C117D /* Project object */ = { 139 97C146E61CF9000F007C117D /* Project object */ = {
140 isa = PBXProject; 140 isa = PBXProject;
141 attributes = { 141 attributes = {
142 - LastUpgradeCheck = 0910; 142 + LastUpgradeCheck = 1300;
143 ORGANIZATIONNAME = "The Chromium Authors"; 143 ORGANIZATIONNAME = "The Chromium Authors";
144 TargetAttributes = { 144 TargetAttributes = {
145 97C146ED1CF9000F007C117D = { 145 97C146ED1CF9000F007C117D = {
@@ -292,7 +292,7 @@ @@ -292,7 +292,7 @@
292 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 292 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
293 GCC_WARN_UNUSED_FUNCTION = YES; 293 GCC_WARN_UNUSED_FUNCTION = YES;
294 GCC_WARN_UNUSED_VARIABLE = YES; 294 GCC_WARN_UNUSED_VARIABLE = YES;
295 - IPHONEOS_DEPLOYMENT_TARGET = 8.0; 295 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
296 MTL_ENABLE_DEBUG_INFO = YES; 296 MTL_ENABLE_DEBUG_INFO = YES;
297 ONLY_ACTIVE_ARCH = YES; 297 ONLY_ACTIVE_ARCH = YES;
298 SDKROOT = iphoneos; 298 SDKROOT = iphoneos;
@@ -339,7 +339,7 @@ @@ -339,7 +339,7 @@
339 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
340 GCC_WARN_UNUSED_FUNCTION = YES; 340 GCC_WARN_UNUSED_FUNCTION = YES;
341 GCC_WARN_UNUSED_VARIABLE = YES; 341 GCC_WARN_UNUSED_VARIABLE = YES;
342 - IPHONEOS_DEPLOYMENT_TARGET = 8.0; 342 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
343 MTL_ENABLE_DEBUG_INFO = NO; 343 MTL_ENABLE_DEBUG_INFO = NO;
344 SDKROOT = iphoneos; 344 SDKROOT = iphoneos;
345 TARGETED_DEVICE_FAMILY = "1,2"; 345 TARGETED_DEVICE_FAMILY = "1,2";
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "0910" 3 + LastUpgradeVersion = "1300"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 2 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 3
4 -void main() => runApp(MyApp()); 4 +void main() {
  5 + runApp(MyApp());
  6 +}
5 7
6 class MyApp extends StatelessWidget { 8 class MyApp extends StatelessWidget {
7 @override 9 @override
@@ -9,6 +11,8 @@ class MyApp extends StatelessWidget { @@ -9,6 +11,8 @@ class MyApp extends StatelessWidget {
9 //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) 11 //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)
10 return ScreenUtilInit( 12 return ScreenUtilInit(
11 designSize: Size(360, 690), 13 designSize: Size(360, 690),
  14 + minTextAdapt: true,
  15 + splitScreenMode: true,
12 builder: () => MaterialApp( 16 builder: () => MaterialApp(
13 debugShowCheckedModeBanner: false, 17 debugShowCheckedModeBanner: false,
14 title: 'Flutter_ScreenUtil', 18 title: 'Flutter_ScreenUtil',
@@ -17,6 +21,7 @@ class MyApp extends StatelessWidget { @@ -17,6 +21,7 @@ class MyApp extends StatelessWidget {
17 textTheme: TextTheme(button: TextStyle(fontSize: 45.sp)), 21 textTheme: TextTheme(button: TextStyle(fontSize: 45.sp)),
18 ), 22 ),
19 builder: (context, widget) { 23 builder: (context, widget) {
  24 + ScreenUtil.setContext(context);
20 return MediaQuery( 25 return MediaQuery(
21 //Setting font does not change with system font size 26 //Setting font does not change with system font size
22 data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), 27 data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
@@ -85,7 +90,7 @@ class _HomePageState extends State<HomePage> { @@ -85,7 +90,7 @@ class _HomePageState extends State<HomePage> {
85 ], 90 ],
86 ), 91 ),
87 Container( 92 Container(
88 - padding: EdgeInsets.all(ScreenUtil().setWidth(10)), 93 + padding: EdgeInsets.all(10.w),
89 width: 100.r, 94 width: 100.r,
90 height: 100.r, 95 height: 100.r,
91 color: Colors.green, 96 color: Colors.green,
@@ -93,7 +98,7 @@ class _HomePageState extends State<HomePage> { @@ -93,7 +98,7 @@ class _HomePageState extends State<HomePage> {
93 'I am a square with a side length of 100', 98 'I am a square with a side length of 100',
94 style: TextStyle( 99 style: TextStyle(
95 color: Colors.white, 100 color: Colors.white,
96 - fontSize: ScreenUtil().setSp(12), 101 + fontSize: 12.sp,
97 ), 102 ),
98 ), 103 ),
99 ), 104 ),
  1 +import 'dart:ui';
  2 +
1 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 5
@@ -35,6 +37,7 @@ class _HomePageState extends State<HomePage> { @@ -35,6 +37,7 @@ class _HomePageState extends State<HomePage> {
35 maxWidth: MediaQuery.of(context).size.width, 37 maxWidth: MediaQuery.of(context).size.width,
36 maxHeight: MediaQuery.of(context).size.height), 38 maxHeight: MediaQuery.of(context).size.height),
37 designSize: Size(360, 690), 39 designSize: Size(360, 690),
  40 + context: context,
38 ); 41 );
39 printScreenInformation(); 42 printScreenInformation();
40 return Scaffold( 43 return Scaffold(
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 // Generated file. Do not edit. 2 // Generated file. Do not edit.
3 // 3 //
4 4
  5 +// clang-format off
  6 +
5 #include "generated_plugin_registrant.h" 7 #include "generated_plugin_registrant.h"
6 8
7 9
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 // Generated file. Do not edit. 2 // Generated file. Do not edit.
3 // 3 //
4 4
  5 +// clang-format off
  6 +
5 #ifndef GENERATED_PLUGIN_REGISTRANT_ 7 #ifndef GENERATED_PLUGIN_REGISTRANT_
6 #define GENERATED_PLUGIN_REGISTRANT_ 8 #define GENERATED_PLUGIN_REGISTRANT_
7 9
@@ -7,6 +7,7 @@ library flutter_screenutil; @@ -7,6 +7,7 @@ library flutter_screenutil;
7 7
8 import 'dart:math'; 8 import 'dart:math';
9 import 'dart:ui' as ui; 9 import 'dart:ui' as ui;
  10 +import 'dart:ui';
10 11
11 import 'package:flutter/material.dart'; 12 import 'package:flutter/material.dart';
12 13
@@ -15,12 +15,10 @@ class ScreenUtil { @@ -15,12 +15,10 @@ class ScreenUtil {
15 ///屏幕方向 15 ///屏幕方向
16 late Orientation _orientation; 16 late Orientation _orientation;
17 17
18 - late double _pixelRatio;  
19 - late double _textScaleFactor;  
20 late double _screenWidth; 18 late double _screenWidth;
21 late double _screenHeight; 19 late double _screenHeight;
22 - late double _statusBarHeight;  
23 - late double _bottomBarHeight; 20 + late bool _minTextAdapt;
  21 + late BuildContext? context;
24 22
25 ScreenUtil._(); 23 ScreenUtil._();
26 24
@@ -28,22 +26,27 @@ class ScreenUtil { @@ -28,22 +26,27 @@ class ScreenUtil {
28 return _instance; 26 return _instance;
29 } 27 }
30 28
  29 + static void setContext(BuildContext context) {
  30 + _instance.context = context;
  31 + }
  32 +
31 static void init( 33 static void init(
32 BoxConstraints constraints, { 34 BoxConstraints constraints, {
  35 + BuildContext? context,
33 Orientation orientation = Orientation.portrait, 36 Orientation orientation = Orientation.portrait,
34 Size designSize = defaultSize, 37 Size designSize = defaultSize,
  38 + bool splitScreenMode = false,
  39 + bool minTextAdapt = false,
35 }) { 40 }) {
36 _instance = ScreenUtil._() 41 _instance = ScreenUtil._()
37 ..uiSize = designSize 42 ..uiSize = designSize
  43 + .._minTextAdapt = minTextAdapt
38 .._orientation = orientation 44 .._orientation = orientation
39 .._screenWidth = constraints.maxWidth 45 .._screenWidth = constraints.maxWidth
40 - .._screenHeight = constraints.maxHeight;  
41 -  
42 - var window = WidgetsBinding.instance?.window ?? ui.window;  
43 - _instance._pixelRatio = window.devicePixelRatio;  
44 - _instance._statusBarHeight = window.padding.top;  
45 - _instance._bottomBarHeight = window.padding.bottom;  
46 - _instance._textScaleFactor = window.textScaleFactor; 46 + .._screenHeight = splitScreenMode
  47 + ? max(constraints.maxHeight, 700)
  48 + : constraints.maxHeight;
  49 + if (context != null) setContext(context);
47 } 50 }
48 51
49 ///获取屏幕方向 52 ///获取屏幕方向
@@ -52,36 +55,39 @@ class ScreenUtil { @@ -52,36 +55,39 @@ class ScreenUtil {
52 55
53 /// 每个逻辑像素的字体像素数,字体的缩放比例 56 /// 每个逻辑像素的字体像素数,字体的缩放比例
54 /// The number of font pixels for each logical pixel. 57 /// The number of font pixels for each logical pixel.
55 - double get textScaleFactor => _textScaleFactor; 58 + double get textScaleFactor => MediaQuery.of(context!).textScaleFactor;
56 59
57 /// 设备的像素密度 60 /// 设备的像素密度
58 /// The size of the media in logical pixels (e.g, the size of the screen). 61 /// The size of the media in logical pixels (e.g, the size of the screen).
59 - double get pixelRatio => _pixelRatio; 62 + double? get pixelRatio => MediaQuery.of(context!).devicePixelRatio;
60 63
61 /// 当前设备宽度 dp 64 /// 当前设备宽度 dp
62 /// The horizontal extent of this size. 65 /// The horizontal extent of this size.
63 - double get screenWidth => _screenWidth; 66 + double get screenWidth =>
  67 + context == null ? _screenWidth : MediaQuery.of(context!).size.width;
64 68
65 ///当前设备高度 dp 69 ///当前设备高度 dp
66 ///The vertical extent of this size. dp 70 ///The vertical extent of this size. dp
67 - double get screenHeight => _screenHeight; 71 + double get screenHeight =>
  72 + context == null ? _screenHeight : MediaQuery.of(context!).size.height;
68 73
69 /// 状态栏高度 dp 刘海屏会更高 74 /// 状态栏高度 dp 刘海屏会更高
70 /// The offset from the top, in dp 75 /// The offset from the top, in dp
71 - double get statusBarHeight => _statusBarHeight / _pixelRatio; 76 + double get statusBarHeight => MediaQuery.of(context!).padding.top;
72 77
73 /// 底部安全区距离 dp 78 /// 底部安全区距离 dp
74 /// The offset from the bottom, in dp 79 /// The offset from the bottom, in dp
75 - double get bottomBarHeight => _bottomBarHeight / _pixelRatio; 80 + double get bottomBarHeight => MediaQuery.of(context!).padding.bottom;
76 81
77 /// 实际尺寸与UI设计的比例 82 /// 实际尺寸与UI设计的比例
78 /// The ratio of actual width to UI design 83 /// The ratio of actual width to UI design
79 - double get scaleWidth => _screenWidth / uiSize.width; 84 + double get scaleWidth => screenWidth / uiSize.width;
80 85
81 /// /// The ratio of actual height to UI design 86 /// /// The ratio of actual height to UI design
82 - double get scaleHeight => _screenHeight / uiSize.height; 87 + double get scaleHeight => screenHeight / uiSize.height;
83 88
84 - double get scaleText => min(scaleWidth, scaleHeight); 89 + double get scaleText =>
  90 + _minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth;
85 91
86 /// 根据UI设计的设备宽度适配 92 /// 根据UI设计的设备宽度适配
87 /// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候. 93 /// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候.
@@ -102,7 +108,7 @@ class ScreenUtil { @@ -102,7 +108,7 @@ class ScreenUtil {
102 108
103 ///根据宽度或高度中的较小值进行适配 109 ///根据宽度或高度中的较小值进行适配
104 ///Adapt according to the smaller of width or height 110 ///Adapt according to the smaller of width or height
105 - double radius(num r) => r * scaleText; 111 + double radius(num r) => r * min(scaleWidth, scaleHeight);
106 112
107 ///字体大小适配方法 113 ///字体大小适配方法
108 ///- [fontSize] UI设计上字体的大小,单位dp. 114 ///- [fontSize] UI设计上字体的大小,单位dp.
@@ -5,10 +5,14 @@ class ScreenUtilInit extends StatelessWidget { @@ -5,10 +5,14 @@ class ScreenUtilInit extends StatelessWidget {
5 ScreenUtilInit({ 5 ScreenUtilInit({
6 required this.builder, 6 required this.builder,
7 this.designSize = ScreenUtil.defaultSize, 7 this.designSize = ScreenUtil.defaultSize,
  8 + this.splitScreenMode = false,
  9 + this.minTextAdapt = false,
8 Key? key, 10 Key? key,
9 }) : super(key: key); 11 }) : super(key: key);
10 12
11 final Widget Function() builder; 13 final Widget Function() builder;
  14 + final bool splitScreenMode;
  15 + final bool minTextAdapt;
12 16
13 /// The [Size] of the device in the design draft, in dp 17 /// The [Size] of the device in the design draft, in dp
14 final Size designSize; 18 final Size designSize;
@@ -17,14 +21,16 @@ class ScreenUtilInit extends StatelessWidget { @@ -17,14 +21,16 @@ class ScreenUtilInit extends StatelessWidget {
17 Widget build(BuildContext context) { 21 Widget build(BuildContext context) {
18 return LayoutBuilder(builder: (_, BoxConstraints constraints) { 22 return LayoutBuilder(builder: (_, BoxConstraints constraints) {
19 if (constraints.maxWidth != 0) { 23 if (constraints.maxWidth != 0) {
20 - final Orientation orientation = constraints.maxWidth > constraints.maxHeight 24 + final Orientation orientation =
  25 + constraints.maxWidth > constraints.maxHeight
21 ? Orientation.landscape 26 ? Orientation.landscape
22 : Orientation.portrait; 27 : Orientation.portrait;
23 - ScreenUtil.init(  
24 - constraints, 28 + ScreenUtil.init(constraints,
  29 + context: _,
25 orientation: orientation, 30 orientation: orientation,
26 designSize: designSize, 31 designSize: designSize,
27 - ); 32 + splitScreenMode: splitScreenMode,
  33 + minTextAdapt: minTextAdapt);
28 return builder(); 34 return builder();
29 } 35 }
30 return Container(); 36 return Container();
@@ -13,14 +13,10 @@ extension SizeExtension on num { @@ -13,14 +13,10 @@ extension SizeExtension on num {
13 ///[ScreenUtil.setSp] 13 ///[ScreenUtil.setSp]
14 double get sp => ScreenUtil().setSp(this); 14 double get sp => ScreenUtil().setSp(this);
15 15
16 - ///[ScreenUtil.setSp]  
17 - @Deprecated('please use [sp]')  
18 - double get ssp => ScreenUtil().setSp(this);  
19 -  
20 - ///[ScreenUtil.setSp]  
21 - @Deprecated(  
22 - 'please use [sp] , and set textScaleFactor: 1.0 , for example: Text("text", textScaleFactor: 1.0)')  
23 - double get nsp => ScreenUtil().setSp(this); 16 + ///smart size : it check your value - if it is bigger than your value it will set your value
  17 + ///for example, you have set 16.sm() , if for your screen 16.sp() is bigger than 16 , then it will set 16 not 16.sp()
  18 + ///I think that it is good for save size balance on big sizes of screen
  19 + double get sm => min(toDouble(), sp);
24 20
25 ///屏幕宽度的倍数 21 ///屏幕宽度的倍数
26 ///Multiple of screen width 22 ///Multiple of screen width
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: 5.0.0+2 3 +version: 5.1.1
4 homepage: https://github.com/OpenFlutter/flutter_screenutil 4 homepage: https://github.com/OpenFlutter/flutter_screenutil
  5 +publish_to: https://pub.dev
5 6
6 environment: 7 environment:
7 sdk: ">=2.12.0 <3.0.0" 8 sdk: ">=2.12.0 <3.0.0"