@@ -58,13 +58,11 @@ class MyApp extends StatelessWidget {
5858 }
5959}
6060```
61- The second way:
61+ The second way: Does not support the use of font adaptation in the App
6262```
6363class MyApp extends StatelessWidget {
6464 @override
6565 Widget build(BuildContext context) {
66- //Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the 360*690
67- ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
6866 return MaterialApp(
6967 debugShowCheckedModeBanner: false,
7068 title: 'Flutter_ScreenUtil',
@@ -75,6 +73,30 @@ class MyApp extends StatelessWidget {
7573 );
7674 }
7775}
76+
77+ class HomePage extends StatefulWidget {
78+ const HomePage({Key key, this.title}) : super(key: key);
79+
80+ final String title;
81+
82+ @override
83+ _HomePageState createState() => _HomePageState();
84+ }
85+
86+ class _HomePageState extends State<HomePage> {
87+ @override
88+ Widget build(BuildContext context) {
89+ //Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the 360*690(dp)
90+ ScreenUtil.init(
91+ BoxConstraints(
92+ maxWidth: MediaQuery.of(context).size.width,
93+ maxHeight: MediaQuery.of(context).size.height),
94+ designSize: Size(360, 690),
95+ allowFontScaling: false,
96+ orientation: Orientation.portrait);
97+ return Scaffold();
98+ }
99+ }
78100```
79101
80102### Use:
0 commit comments