Skip to content

Commit bc93072

Browse files
committed
3.1.0
fix #153 #154
1 parent 6ea1529 commit bc93072

File tree

10 files changed

+105
-109
lines changed

10 files changed

+105
-109
lines changed

.flutter_tool_state

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"is-bot": true,
3+
"redisplay-welcome-message": false
4+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
* @LastEditTime: 2020年6月20日 11:20:02
66
* @Description: Update log
77
-->
8+
9+
# 3.1.0
10+
- Use the way back to v2 version
11+
- Modify registration method
12+
813
# 3.0.2+1
914
- Guide users to use V2 version
1015

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Please use [v2](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/2.3.1),[v3](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/3.0.2) now has some bugs.
2-
31
# flutter_screenutil
42
[![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dev/packages/flutter_screenutil)
53

@@ -30,7 +28,7 @@ dependencies:
3028
flutter:
3129
sdk: flutter
3230
# add flutter_screenutil
33-
flutter_screenutil: ^2.3.1
31+
flutter_screenutil: ^3.1.0
3432
```
3533
### Add the following imports to your Dart code:
3634
```
@@ -59,13 +57,13 @@ void main() {
5957
//fill in the screen size of the device in the design
6058
6159
//default value : width : 1080px , height:1920px , allowFontScaling:false
62-
ScreenUtil.init();
60+
ScreenUtil.init(context);
6361
6462
//If the design is based on the size of the iPhone6 ​​(iPhone6 ​​750*1334)
65-
ScreenUtil.init(designSize: Size(750, 1334));
63+
ScreenUtil.init(context, designSize: Size(750, 1334));
6664
6765
//If you want to set the font size is scaled according to the system's "font size" assist option
68-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
66+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
6967
7068
```
7169

README_CN.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# 请使用[v2](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/2.3.1),[v3](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/3.0.2)现在有一些bug
2-
31
# flutter_ScreenUtil
42

53
[![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil)
@@ -35,7 +33,7 @@ dependencies:
3533
flutter:
3634
sdk: flutter
3735
# 添加依赖
38-
flutter_screenutil: ^2.3.1
36+
flutter_screenutil: ^3.1.0
3937
```
4038
### 在每个使用的地方导入包:
4139
```
@@ -64,13 +62,13 @@ void main() {
6462
}
6563
6664
//默认 width : 1080px , height:1920px , allowFontScaling:false
67-
ScreenUtil.init();
65+
ScreenUtil.init(context);
6866
6967
//假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
70-
ScreenUtil.init(designSize: Size(750, 1334));
68+
ScreenUtil.init(context, designSize: Size(750, 1334));
7169
7270
//设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false
73-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
71+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7472
7573
```
7674

@@ -182,12 +180,10 @@ Column(
182180
```
183181

184182
```dart
185-
void main() {
186-
WidgetsFlutterBinding.ensureInitialized();
187-
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
188-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
189-
runApp(MyApp());
190-
}
183+
import 'package:flutter/material.dart';
184+
import 'package:flutter_screenutil/flutter_screenutil.dart';
185+
186+
void main() => runApp(MyApp());
191187
192188
class MyApp extends StatelessWidget {
193189
@override
@@ -198,11 +194,20 @@ class MyApp extends StatelessWidget {
198194
theme: ThemeData(
199195
primarySwatch: Colors.blue,
200196
),
201-
home: ExampleWidget(title: 'FlutterScreenUtil示例'),
197+
home: MyHomePage(),
202198
);
203199
}
204200
}
205201
202+
class MyHomePage extends StatelessWidget {
203+
@override
204+
Widget build(BuildContext context) {
205+
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
206+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
207+
return ExampleWidget(title: 'FlutterScreenUtil 示例');
208+
}
209+
}
210+
206211
class ExampleWidget extends StatefulWidget {
207212
const ExampleWidget({Key key, this.title}) : super(key: key);
208213
@@ -234,8 +239,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
234239
child: Text(
235240
'我的宽度:${0.5.wp}dp \n'
236241
'我的高度:${ScreenUtil().setHeight(200)}dp',
237-
style: TextStyle(
238-
color: Colors.white, fontSize: ScreenUtil().setSp(24)),
242+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
239243
),
240244
),
241245
Container(
@@ -246,9 +250,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
246250
child: Text(
247251
'我的宽度:${375.w}dp \n'
248252
'我的高度:${200.h}dp',
249-
style: TextStyle(
250-
color: Colors.white,
251-
fontSize: ScreenUtil().setSp(24))),
253+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24))),
252254
),
253255
],
254256
),
@@ -276,11 +278,17 @@ class _ExampleWidgetState extends State<ExampleWidget> {
276278
children: <Widget>[
277279
Text(
278280
'我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化',
279-
style: ts.t2,
281+
style: TextStyle(
282+
color: Colors.black,
283+
fontSize: 24.sp,
284+
),
280285
),
281286
Text(
282287
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化',
283-
style: ts.t1,
288+
style: TextStyle(
289+
color: Colors.black,
290+
fontSize: 24.ssp,
291+
),
284292
),
285293
],
286294
)
@@ -291,7 +299,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
291299
child: Icon(Icons.title),
292300
onPressed: () {
293301
ScreenUtil.init(
294-
designSize: Size(1500, 1334),
302+
context,
303+
designSize: Size(750, 1334),
295304
allowFontScaling: false,
296305
);
297306
setState(() {});

README_PT.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Please use [v2](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/2.3.1),[v3](https://pub.flutter-io.cn/packages/flutter_screenutil/versions/3.0.2) now has some bugs.
2-
31
# flutter_screenutil
42
[![pub package](https://img.shields.io/pub/v/flutter_screenutil.svg)](https://pub.dartlang.org/packages/flutter_screenutil)
53

@@ -30,7 +28,7 @@ dependencies:
3028
flutter:
3129
sdk: flutter
3230
# add flutter_screenutil
33-
flutter_screenutil: ^2.3.1
31+
flutter_screenutil: ^3.1.0
3432
```
3533

3634
### Adicione o seguinte import em seu código Dart:
@@ -60,13 +58,13 @@ void main() {
6058
}
6159
6260
//Valor padrão: width : 1080px , height:1920px , allowFontScaling:false
63-
ScreenUtil.init();
61+
ScreenUtil.init(context);
6462
6563
//Se o design é baseado no iPhone6 ​​(iPhone6 ​​750*1334)
66-
ScreenUtil.init(designSize: Size(750, 1334));
64+
ScreenUtil.init(context, designSize: Size(750, 1334));
6765
6866
//Se você quer definir que o tamanho da fonte seja ajustado de acordo com a opção "tamanho da fonte" na acessibilidade do sistema
69-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
67+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7068
7169
```
7270

example/lib/main.dart

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ import 'dart:ui';
33
import 'package:flutter/material.dart';
44
import 'package:flutter_screenutil/flutter_screenutil.dart';
55

6-
import 'text_style.dart';
7-
8-
void main() {
9-
WidgetsFlutterBinding.ensureInitialized();
10-
//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-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
12-
runApp(MyApp());
13-
}
6+
void main() => runApp(MyApp());
147

158
class MyApp extends StatelessWidget {
169
@override
@@ -21,11 +14,20 @@ class MyApp extends StatelessWidget {
2114
theme: ThemeData(
2215
primarySwatch: Colors.blue,
2316
),
24-
home: ExampleWidget(title: 'FlutterScreenUtil Demo'),
17+
home: MyHomePage(),
2518
);
2619
}
2720
}
2821

22+
class MyHomePage extends StatelessWidget {
23+
@override
24+
Widget build(BuildContext context) {
25+
//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)
26+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
27+
return ExampleWidget(title: 'FlutterScreenUtil Demo');
28+
}
29+
}
30+
2931
class ExampleWidget extends StatefulWidget {
3032
const ExampleWidget({Key key, this.title}) : super(key: key);
3133

@@ -38,6 +40,9 @@ class ExampleWidget extends StatefulWidget {
3840
class _ExampleWidgetState extends State<ExampleWidget> {
3941
@override
4042
Widget build(BuildContext context) {
43+
//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)
44+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
45+
4146
printScreenInformation();
4247
return Scaffold(
4348
appBar: AppBar(
@@ -112,7 +117,10 @@ class _ExampleWidgetState extends State<ExampleWidget> {
112117
),
113118
Text(
114119
'My font size is 24px on the design draft and will change with the system.',
115-
style: ts.t1,
120+
style: TextStyle(
121+
color: Colors.black,
122+
fontSize: 24.ssp,
123+
),
116124
),
117125
],
118126
)
@@ -122,10 +130,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
122130
floatingActionButton: FloatingActionButton(
123131
child: Icon(Icons.title),
124132
onPressed: () {
125-
ScreenUtil.init(
126-
designSize: Size(750, 1334),
127-
allowFontScaling: false,
128-
);
133+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
129134
setState(() {});
130135
},
131136
),
@@ -151,4 +156,3 @@ class _ExampleWidgetState extends State<ExampleWidget> {
151156
print('0.5 times the screen height:${0.5.hp}');
152157
}
153158
}
154-

example/lib/main_zh.dart

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_screenutil/flutter_screenutil.dart';
33

4-
import 'text_style.dart';
5-
6-
void main() {
7-
WidgetsFlutterBinding.ensureInitialized();
8-
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
9-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
10-
runApp(MyApp());
11-
}
4+
void main() => runApp(MyApp());
125

136
class MyApp extends StatelessWidget {
147
@override
@@ -19,11 +12,20 @@ class MyApp extends StatelessWidget {
1912
theme: ThemeData(
2013
primarySwatch: Colors.blue,
2114
),
22-
home: ExampleWidget(title: 'FlutterScreenUtil示例'),
15+
home: MyHomePage(),
2316
);
2417
}
2518
}
2619

20+
class MyHomePage extends StatelessWidget {
21+
@override
22+
Widget build(BuildContext context) {
23+
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
24+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
25+
return ExampleWidget(title: 'FlutterScreenUtil 示例');
26+
}
27+
}
28+
2729
class ExampleWidget extends StatefulWidget {
2830
const ExampleWidget({Key key, this.title}) : super(key: key);
2931

@@ -55,8 +57,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
5557
child: Text(
5658
'我的宽度:${0.5.wp}dp \n'
5759
'我的高度:${ScreenUtil().setHeight(200)}dp',
58-
style: TextStyle(
59-
color: Colors.white, fontSize: ScreenUtil().setSp(24)),
60+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
6061
),
6162
),
6263
Container(
@@ -67,9 +68,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
6768
child: Text(
6869
'我的宽度:${375.w}dp \n'
6970
'我的高度:${200.h}dp',
70-
style: TextStyle(
71-
color: Colors.white,
72-
fontSize: ScreenUtil().setSp(24))),
71+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24))),
7372
),
7473
],
7574
),
@@ -97,11 +96,17 @@ class _ExampleWidgetState extends State<ExampleWidget> {
9796
children: <Widget>[
9897
Text(
9998
'我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化',
100-
style: ts.t2,
99+
style: TextStyle(
100+
color: Colors.black,
101+
fontSize: 24.sp,
102+
),
101103
),
102104
Text(
103105
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化',
104-
style: ts.t1,
106+
style: TextStyle(
107+
color: Colors.black,
108+
fontSize: 24.ssp,
109+
),
105110
),
106111
],
107112
)
@@ -112,6 +117,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
112117
child: Icon(Icons.title),
113118
onPressed: () {
114119
ScreenUtil.init(
120+
context,
115121
designSize: Size(750, 1334),
116122
allowFontScaling: false,
117123
);

example/lib/text_style.dart

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)