Skip to content

Commit

Permalink
Merge pull request OpenFlutter#218 from ytx222/patch-2
Browse files Browse the repository at this point in the history
修改为新版的初始化
  • Loading branch information
lizhuoyuan authored Feb 21, 2021
2 parents e53982f + 9b5bb33 commit ae9af6d
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 ae9af6d

Please sign in to comment.