Skip to content

Commit 0542853

Browse files
author
李卓原
committed
# 5.0.0-nullsafety.9
添加新的初始化方式
1 parent f29a851 commit 0542853

File tree

6 files changed

+87
-12
lines changed

6 files changed

+87
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 5.0.0-nullsafety.9
2+
- Supplementary documentation, supports two initialization methods
3+
14
# 5.0.0-nullsafety.8
25
- merge v4
36
- Add a method to get the screen orientation

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ class MyApp extends StatelessWidget {
5858
}
5959
}
6060
```
61-
The second way:
61+
The second way:Does not support the use of font adaptation in the App
6262
```
6363
class MyApp extends StatelessWidget {
6464
@override
6565
Widget build(BuildContext context) {
66-
//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 360*690
67-
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
6866
return MaterialApp(
6967
debugShowCheckedModeBanner: false,
7068
title: 'Flutter_ScreenUtil',
@@ -75,6 +73,30 @@ class MyApp extends StatelessWidget {
7573
);
7674
}
7775
}
76+
77+
class HomePage extends StatefulWidget {
78+
const HomePage({Key key, this.title}) : super(key: key);
79+
80+
final String title;
81+
82+
@override
83+
_HomePageState createState() => _HomePageState();
84+
}
85+
86+
class _HomePageState extends State<HomePage> {
87+
@override
88+
Widget build(BuildContext context) {
89+
//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 360*690(dp)
90+
ScreenUtil.init(
91+
BoxConstraints(
92+
maxWidth: MediaQuery.of(context).size.width,
93+
maxHeight: MediaQuery.of(context).size.height),
94+
designSize: Size(360, 690),
95+
allowFontScaling: false,
96+
orientation: Orientation.portrait);
97+
return Scaffold();
98+
}
99+
}
78100
```
79101

80102
### Use:

README_CN.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ class MyApp extends StatelessWidget {
6969
}
7070
}
7171
```
72-
方式二:
72+
方式二: 不支持在App中使用字体适配
7373
```
7474
class MyApp extends StatelessWidget {
7575
@override
7676
Widget build(BuildContext context) {
77-
//填入设计稿中设备的屏幕尺寸 (例如:360*690) , 单位dp
78-
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
7977
return MaterialApp(
8078
debugShowCheckedModeBanner: false,
8179
title: 'Flutter_ScreenUtil',
@@ -86,6 +84,30 @@ class MyApp extends StatelessWidget {
8684
);
8785
}
8886
}
87+
88+
class HomePage extends StatefulWidget {
89+
const HomePage({Key key, this.title}) : super(key: key);
90+
91+
final String title;
92+
93+
@override
94+
_HomePageState createState() => _HomePageState();
95+
}
96+
97+
class _HomePageState extends State<HomePage> {
98+
@override
99+
Widget build(BuildContext context) {
100+
//设置尺寸(填写设计中设备的屏幕尺寸)如果设计基于360dp * 690dp的屏幕
101+
ScreenUtil.init(
102+
BoxConstraints(
103+
maxWidth: MediaQuery.of(context).size.width,
104+
maxHeight: MediaQuery.of(context).size.height),
105+
designSize: Size(360, 690),
106+
allowFontScaling: false,
107+
orientation: Orientation.portrait);
108+
return Scaffold();
109+
}
110+
}
89111
```
90112

91113
### 使用

README_PT.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ class MyApp extends StatelessWidget {
6262
}
6363
}
6464
```
65-
The second way:
65+
The second way:Does not support the use of font adaptation in the App
6666
```
6767
class MyApp extends StatelessWidget {
6868
@override
6969
Widget build(BuildContext context) {
70-
//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 360*690
71-
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
7270
return MaterialApp(
7371
debugShowCheckedModeBanner: false,
7472
title: 'Flutter_ScreenUtil',
@@ -79,6 +77,30 @@ class MyApp extends StatelessWidget {
7977
);
8078
}
8179
}
80+
81+
class HomePage extends StatefulWidget {
82+
const HomePage({Key key, this.title}) : super(key: key);
83+
84+
final String title;
85+
86+
@override
87+
_HomePageState createState() => _HomePageState();
88+
}
89+
90+
class _HomePageState extends State<HomePage> {
91+
@override
92+
Widget build(BuildContext context) {
93+
//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 360*690(dp)
94+
ScreenUtil.init(
95+
BoxConstraints(
96+
maxWidth: MediaQuery.of(context).size.width,
97+
maxHeight: MediaQuery.of(context).size.height),
98+
designSize: Size(360, 690),
99+
allowFontScaling: false,
100+
orientation: Orientation.portrait);
101+
return Scaffold();
102+
}
103+
}
82104
```
83105

84106
### Uso:

example/lib/main_zh.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ void main() => runApp(MyApp());
66
class MyApp extends StatelessWidget {
77
@override
88
Widget build(BuildContext context) {
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 360*690
10-
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
119
return MaterialApp(
1210
debugShowCheckedModeBanner: false,
1311
title: 'Flutter_ScreenUtil',
@@ -31,6 +29,14 @@ class HomePage extends StatefulWidget {
3129
class _HomePageState extends State<HomePage> {
3230
@override
3331
Widget build(BuildContext context) {
32+
//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 360*690
33+
ScreenUtil.init(
34+
BoxConstraints(
35+
maxWidth: MediaQuery.of(context).size.width,
36+
maxHeight: MediaQuery.of(context).size.height),
37+
designSize: Size(360, 690),
38+
allowFontScaling: false,
39+
orientation: Orientation.portrait);
3440
printScreenInformation();
3541
return Scaffold(
3642
appBar: AppBar(

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_screenutil
22
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
3-
version: 5.0.0-nullsafety.8
3+
version: 5.0.0-nullsafety.9
44
homepage: https://github.com/OpenFlutter/flutter_screenutil
55

66
environment:

0 commit comments

Comments
 (0)