LiZhuoyuan
Committed by GitHub

Merge pull request #218 from ytx222/patch-2

修改为新版的初始化
@@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
49 ```dart 49 ```dart
50 //填入设计稿中设备的屏幕尺寸 50 //填入设计稿中设备的屏幕尺寸
51 51
52 -void main() => runApp(MyApp()); 52 +class HomePage extends StatelessWidget {
  53 + const HomePage({Key key}) : super(key: key);
53 54
54 -class MyApp extends StatelessWidget {  
55 @override 55 @override
56 Widget build(BuildContext context) { 56 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,
63 ), 63 ),
  64 + // 设计尺寸
  65 + designSize: Size(750, 1334),
  66 + allowFontScaling: false,
  67 + );
  68 + return Container(
  69 + child: child,
64 ); 70 );
65 } 71 }
66 } 72 }