Committed by
GitHub
Merge pull request #211 from idootop/master
fix #196, #209
Showing
6 changed files
with
8 additions
and
8 deletions
@@ -50,7 +50,7 @@ class MyApp extends StatelessWidget { | @@ -50,7 +50,7 @@ class MyApp extends StatelessWidget { | ||
50 | return ScreenUtilInit( | 50 | return ScreenUtilInit( |
51 | designSize: Size(360, 690), | 51 | designSize: Size(360, 690), |
52 | allowFontScaling: false, | 52 | allowFontScaling: false, |
53 | - child: MaterialApp( | 53 | + builder: () => MaterialApp( |
54 | ... | 54 | ... |
55 | ), | 55 | ), |
56 | ); | 56 | ); |
@@ -58,7 +58,7 @@ class MyApp extends StatelessWidget { | @@ -58,7 +58,7 @@ class MyApp extends StatelessWidget { | ||
58 | return ScreenUtilInit( | 58 | return ScreenUtilInit( |
59 | designSize: Size(360, 690), | 59 | designSize: Size(360, 690), |
60 | allowFontScaling: false, | 60 | allowFontScaling: false, |
61 | - child: MaterialApp( | 61 | + builder: () => MaterialApp( |
62 | ... | 62 | ... |
63 | ), | 63 | ), |
64 | ); | 64 | ); |
@@ -54,7 +54,7 @@ class MyApp extends StatelessWidget { | @@ -54,7 +54,7 @@ class MyApp extends StatelessWidget { | ||
54 | return ScreenUtilInit( | 54 | return ScreenUtilInit( |
55 | designSize: Size(360, 690), | 55 | designSize: Size(360, 690), |
56 | allowFontScaling: false, | 56 | allowFontScaling: false, |
57 | - child: MaterialApp( | 57 | + builder: () => MaterialApp( |
58 | ... | 58 | ... |
59 | ), | 59 | ), |
60 | ); | 60 | ); |
@@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { | @@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { | ||
10 | return ScreenUtilInit( | 10 | return ScreenUtilInit( |
11 | designSize: Size(360, 690), | 11 | designSize: Size(360, 690), |
12 | allowFontScaling: false, | 12 | allowFontScaling: false, |
13 | - child: MaterialApp( | 13 | + builder: () => MaterialApp( |
14 | debugShowCheckedModeBanner: false, | 14 | debugShowCheckedModeBanner: false, |
15 | title: 'Flutter_ScreenUtil', | 15 | title: 'Flutter_ScreenUtil', |
16 | theme: ThemeData( | 16 | theme: ThemeData( |
@@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { | @@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { | ||
10 | return ScreenUtilInit( | 10 | return ScreenUtilInit( |
11 | designSize: Size(750, 1334), | 11 | designSize: Size(750, 1334), |
12 | allowFontScaling: false, | 12 | allowFontScaling: false, |
13 | - child: MaterialApp( | 13 | + builder: () => MaterialApp( |
14 | debugShowCheckedModeBanner: false, | 14 | debugShowCheckedModeBanner: false, |
15 | title: 'Flutter_ScreenUtil', | 15 | title: 'Flutter_ScreenUtil', |
16 | theme: ThemeData( | 16 | theme: ThemeData( |
@@ -5,13 +5,13 @@ import 'screenutil.dart'; | @@ -5,13 +5,13 @@ import 'screenutil.dart'; | ||
5 | class ScreenUtilInit extends StatelessWidget { | 5 | class ScreenUtilInit extends StatelessWidget { |
6 | /// A helper widget that initializes [ScreenUtil] | 6 | /// A helper widget that initializes [ScreenUtil] |
7 | ScreenUtilInit({ | 7 | ScreenUtilInit({ |
8 | - required this.child, | 8 | + required this.builder, |
9 | this.designSize = ScreenUtil.defaultSize, | 9 | this.designSize = ScreenUtil.defaultSize, |
10 | this.allowFontScaling = false, | 10 | this.allowFontScaling = false, |
11 | Key? key, | 11 | Key? key, |
12 | }) : super(key: key); | 12 | }) : super(key: key); |
13 | 13 | ||
14 | - final Widget child; | 14 | + final Widget Function() builder; |
15 | 15 | ||
16 | /// The [Size] of the device in the design draft, in dp | 16 | /// The [Size] of the device in the design draft, in dp |
17 | final Size designSize; | 17 | final Size designSize; |
@@ -31,7 +31,7 @@ class ScreenUtilInit extends StatelessWidget { | @@ -31,7 +31,7 @@ class ScreenUtilInit extends StatelessWidget { | ||
31 | allowFontScaling: allowFontScaling, | 31 | allowFontScaling: allowFontScaling, |
32 | ); | 32 | ); |
33 | } | 33 | } |
34 | - return child; | 34 | + return builder(); |
35 | }, | 35 | }, |
36 | ); | 36 | ); |
37 | } | 37 | } |
-
Please register or login to post a comment