李卓原

# 5.0.0-nullsafety.9

添加新的初始化方式
# 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
... ...
... ... @@ -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',
... ... @@ -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:
... ...
... ... @@ -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',
... ... @@ -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();
}
}
```
### 使用
... ...
... ... @@ -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',
... ... @@ -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:
... ...
... ... @@ -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',
... ... @@ -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(
... ...
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:
... ...