Skip to content

Commit faa60f9

Browse files
author
李卓原
committed
Merge remote-tracking branch 'origin/master'
2 parents 115e489 + 5240c03 commit faa60f9

File tree

11 files changed

+127
-133
lines changed

11 files changed

+127
-133
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
* @LastEditTime: 2020年6月20日 11:20:02
66
* @Description: Update log
77
-->
8+
9+
# 3.1.1
10+
- change readme
11+
12+
# 3.1.0
13+
- Use the way back to v2 version
14+
- Modify registration method
15+
16+
# 3.0.2+1
17+
- Guide users to use V2 version
18+
819
# 3.0.2
920
- Change the unit of'statusBarHeight' and 'bottomBarHeight' to dp
1021

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
[Update log](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)
1515

16-
## Note
17-
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta) requires `flutter >= 1.19.0`.
18-
19-
[v2](https://github.com/OpenFlutter/flutter_screenutil) support all versions.
20-
2116
## Usage:
2217

2318
### Add dependency:
@@ -28,7 +23,7 @@ dependencies:
2823
flutter:
2924
sdk: flutter
3025
# add flutter_screenutil
31-
flutter_screenutil: ^3.0.2
26+
flutter_screenutil: ^3.1.0
3227
```
3328
### Add the following imports to your Dart code:
3429
```
@@ -50,20 +45,20 @@ Please set the size of the design draft before use, the width and height of the
5045
void main() {
5146
WidgetsFlutterBinding.ensureInitialized();
5247
//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)
53-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
48+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
5449
runApp(MyApp());
5550
}
5651
5752
//fill in the screen size of the device in the design
5853
5954
//default value : width : 1080px , height:1920px , allowFontScaling:false
60-
ScreenUtil.init();
55+
ScreenUtil.init(context);
6156
6257
//If the design is based on the size of the iPhone6 ​​(iPhone6 ​​750*1334)
63-
ScreenUtil.init(designSize: Size(750, 1334));
58+
ScreenUtil.init(context, designSize: Size(750, 1334));
6459
6560
//If you want to set the font size is scaled according to the system's "font size" assist option
66-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
61+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
6762
6863
```
6964

README_CN.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
[更新日志](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)
1919

20-
## Note
21-
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta)可用于`flutter >= 1.19.0`
22-
23-
[v2](https://github.com/OpenFlutter/flutter_screenutil)可用于所有版本。
24-
2520
## 使用方法:
2621

2722
### 安装依赖:
@@ -33,7 +28,7 @@ dependencies:
3328
flutter:
3429
sdk: flutter
3530
# 添加依赖
36-
flutter_screenutil: ^3.0.2
31+
flutter_screenutil: ^3.1.0
3732
```
3833
### 在每个使用的地方导入包:
3934
```
@@ -57,18 +52,18 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
5752
void main() {
5853
WidgetsFlutterBinding.ensureInitialized();
5954
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
60-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
55+
ScreenUtil.init(context,designSize: Size(750, 1334), allowFontScaling: false);
6156
runApp(MyApp());
6257
}
6358
6459
//默认 width : 1080px , height:1920px , allowFontScaling:false
65-
ScreenUtil.init();
60+
ScreenUtil.init(context);
6661
6762
//假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
68-
ScreenUtil.init(designSize: Size(750, 1334));
63+
ScreenUtil.init(context, designSize: Size(750, 1334));
6964
7065
//设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false
71-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
66+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
7267
7368
```
7469

@@ -180,12 +175,10 @@ Column(
180175
```
181176

182177
```dart
183-
void main() {
184-
WidgetsFlutterBinding.ensureInitialized();
185-
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
186-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
187-
runApp(MyApp());
188-
}
178+
import 'package:flutter/material.dart';
179+
import 'package:flutter_screenutil/flutter_screenutil.dart';
180+
181+
void main() => runApp(MyApp());
189182
190183
class MyApp extends StatelessWidget {
191184
@override
@@ -196,11 +189,20 @@ class MyApp extends StatelessWidget {
196189
theme: ThemeData(
197190
primarySwatch: Colors.blue,
198191
),
199-
home: ExampleWidget(title: 'FlutterScreenUtil示例'),
192+
home: MyHomePage(),
200193
);
201194
}
202195
}
203196
197+
class MyHomePage extends StatelessWidget {
198+
@override
199+
Widget build(BuildContext context) {
200+
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
201+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
202+
return ExampleWidget(title: 'FlutterScreenUtil 示例');
203+
}
204+
}
205+
204206
class ExampleWidget extends StatefulWidget {
205207
const ExampleWidget({Key key, this.title}) : super(key: key);
206208
@@ -232,8 +234,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
232234
child: Text(
233235
'我的宽度:${0.5.wp}dp \n'
234236
'我的高度:${ScreenUtil().setHeight(200)}dp',
235-
style: TextStyle(
236-
color: Colors.white, fontSize: ScreenUtil().setSp(24)),
237+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
237238
),
238239
),
239240
Container(
@@ -244,9 +245,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
244245
child: Text(
245246
'我的宽度:${375.w}dp \n'
246247
'我的高度:${200.h}dp',
247-
style: TextStyle(
248-
color: Colors.white,
249-
fontSize: ScreenUtil().setSp(24))),
248+
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24))),
250249
),
251250
],
252251
),
@@ -274,11 +273,17 @@ class _ExampleWidgetState extends State<ExampleWidget> {
274273
children: <Widget>[
275274
Text(
276275
'我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化',
277-
style: ts.t2,
276+
style: TextStyle(
277+
color: Colors.black,
278+
fontSize: 24.sp,
279+
),
278280
),
279281
Text(
280282
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化',
281-
style: ts.t1,
283+
style: TextStyle(
284+
color: Colors.black,
285+
fontSize: 24.ssp,
286+
),
282287
),
283288
],
284289
)
@@ -289,7 +294,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
289294
child: Icon(Icons.title),
290295
onPressed: () {
291296
ScreenUtil.init(
292-
designSize: Size(1500, 1334),
297+
context,
298+
designSize: Size(750, 1334),
293299
allowFontScaling: false,
294300
);
295301
setState(() {});

README_PT.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
[Histórico de atualizações](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)
1515

16-
## Note
17-
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta) requer `flutter >= 1.19.0`.
18-
19-
[v2](https://github.com/OpenFlutter/flutter_screenutil) support all versions.
20-
2116
## Como usar:
2217

2318
### Adicionando a dependência:
@@ -28,7 +23,7 @@ dependencies:
2823
flutter:
2924
sdk: flutter
3025
# add flutter_screenutil
31-
flutter_screenutil: ^3.0.2
26+
flutter_screenutil: ^3.1.0
3227
```
3328

3429
### Adicione o seguinte import em seu código Dart:
@@ -53,18 +48,18 @@ Certifique-se de definir as dimensões na paginal inicial do MaterialApp (ou sej
5348
void main() {
5449
WidgetsFlutterBinding.ensureInitialized();
5550
//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)
56-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
51+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
5752
runApp(MyApp());
5853
}
5954
6055
//Valor padrão: width : 1080px , height:1920px , allowFontScaling:false
61-
ScreenUtil.init();
56+
ScreenUtil.init(context);
6257
6358
//Se o design é baseado no iPhone6 ​​(iPhone6 ​​750*1334)
64-
ScreenUtil.init(designSize: Size(750, 1334));
59+
ScreenUtil.init(context, designSize: Size(750, 1334));
6560
6661
//Se você quer definir que o tamanho da fonte seja ajustado de acordo com a opção "tamanho da fonte" na acessibilidade do sistema
67-
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
62+
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
6863
6964
```
7065

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
FlutterApplication and put your custom class here. -->
88
<application
99
android:name="io.flutter.app.FlutterApplication"
10-
android:label="example"
10+
android:label="flutter_screenutil"
1111
android:icon="@mipmap/ic_launcher">
1212
<activity
1313
android:name=".MainActivity"

example/lib/main.dart

Lines changed: 23 additions & 21 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,7 +40,10 @@ class ExampleWidget extends StatefulWidget {
3840
class _ExampleWidgetState extends State<ExampleWidget> {
3941
@override
4042
Widget build(BuildContext context) {
41-
// printScreenInformation();
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+
46+
printScreenInformation();
4247
return Scaffold(
4348
appBar: AppBar(
4449
title: Text(widget.title),
@@ -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
),
@@ -135,16 +140,13 @@ class _ExampleWidgetState extends State<ExampleWidget> {
135140
void printScreenInformation() {
136141
print('Device width dp:${ScreenUtil().screenWidth}'); //Device width
137142
print('Device height dp:${ScreenUtil().screenHeight}'); //Device height
138-
print(
139-
'Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density
143+
print('Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density
140144
print(
141145
'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
142146
print(
143147
'Status bar height px:${ScreenUtil().statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px
144-
print(
145-
'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}');
146-
print(
147-
'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}');
148+
print('Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}');
149+
print('Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}');
148150
print(
149151
'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}');
150152
print(

0 commit comments

Comments
 (0)