File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
49
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
55
@override
56
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
}
You can’t perform that action at this time.
0 commit comments