Skip to content

Commit ae9af6d

Browse files
authored
Merge pull request #218 from ytx222/patch-2
修改为新版的初始化
2 parents e53982f + 9b5bb33 commit ae9af6d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

README_CN.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
4949
```dart
5050
//填入设计稿中设备的屏幕尺寸
5151
52-
void main() => runApp(MyApp());
52+
class HomePage extends StatelessWidget {
53+
const HomePage({Key key}) : super(key: key);
5354
54-
class MyApp extends StatelessWidget {
5555
@override
5656
Widget build(BuildContext context) {
57-
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸,单位dp)
58-
return ScreenUtilInit(
59-
designSize: Size(360, 690),
60-
allowFontScaling: false,
61-
builder: () => MaterialApp(
62-
...
57+
// 初始化
58+
ScreenUtil.init(
59+
// 设备像素大小(必须在首页中获取)
60+
BoxConstraints(
61+
maxWidth: MediaQuery.of(context).size.width,
62+
maxHeight: MediaQuery.of(context).size.height,
6363
),
64+
// 设计尺寸
65+
designSize: Size(750, 1334),
66+
allowFontScaling: false,
67+
);
68+
return Container(
69+
child: child,
6470
);
6571
}
6672
}

0 commit comments

Comments
 (0)