Skip to content

Commit

Permalink
修改为新版的初始化
Browse files Browse the repository at this point in the history
修改为新版的初始化
  • Loading branch information
ytx222 authored Feb 13, 2021
1 parent e53982f commit 9b5bb33
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
```dart
//填入设计稿中设备的屏幕尺寸
void main() => runApp(MyApp());
class HomePage extends StatelessWidget {
const HomePage({Key key}) : super(key: key);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸,单位dp)
return ScreenUtilInit(
designSize: Size(360, 690),
allowFontScaling: false,
builder: () => MaterialApp(
...
// 初始化
ScreenUtil.init(
// 设备像素大小(必须在首页中获取)
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height,
),
// 设计尺寸
designSize: Size(750, 1334),
allowFontScaling: false,
);
return Container(
child: child,
);
}
}
Expand Down

0 comments on commit 9b5bb33

Please sign in to comment.