Skip to content

Commit

Permalink
# 5.0.0-nullsafety.9
Browse files Browse the repository at this point in the history
添加新的初始化方式
  • Loading branch information
李卓原 committed Mar 11, 2021
1 parent f29a851 commit 0542853
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 5.0.0-nullsafety.9
- Supplementary documentation, supports two initialization methods

# 5.0.0-nullsafety.8
- merge v4
- Add a method to get the screen orientation
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ class MyApp extends StatelessWidget {
}
}
```
The second way:
The second way:Does not support the use of font adaptation in the App
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//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
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
Expand All @@ -75,6 +73,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//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)
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```

### Use:
Expand Down
28 changes: 25 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ class MyApp extends StatelessWidget {
}
}
```
方式二:
方式二: 不支持在App中使用字体适配
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//填入设计稿中设备的屏幕尺寸 (例如:360*690) , 单位dp
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
Expand All @@ -86,6 +84,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//设置尺寸(填写设计中设备的屏幕尺寸)如果设计基于360dp * 690dp的屏幕
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```

### 使用
Expand Down
28 changes: 25 additions & 3 deletions README_PT.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ class MyApp extends StatelessWidget {
}
}
```
The second way:
The second way:Does not support the use of font adaptation in the App
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//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
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
Expand All @@ -79,6 +77,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//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)
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```

### Uso:
Expand Down
10 changes: 8 additions & 2 deletions example/lib/main_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//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
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
Expand All @@ -31,6 +29,14 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//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
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
printScreenInformation();
return Scaffold(
appBar: AppBar(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_screenutil
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version: 5.0.0-nullsafety.8
version: 5.0.0-nullsafety.9
homepage: https://github.com/OpenFlutter/flutter_screenutil

environment:
Expand Down

0 comments on commit 0542853

Please sign in to comment.