From 170cbf172b951bfcfdd704e47467621282a6d034 Mon Sep 17 00:00:00 2001 From: WJG Date: Fri, 5 Feb 2021 11:12:52 +0800 Subject: [PATCH] fix #196, #209 --- README.md | 2 +- README_CN.md | 2 +- README_PT.md | 2 +- example/lib/main.dart | 2 +- example/lib/main_zh.dart | 2 +- lib/screenutil_init.dart | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 342e53c..f146760 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ class MyApp extends StatelessWidget { return ScreenUtilInit( designSize: Size(360, 690), allowFontScaling: false, - child: MaterialApp( + builder: () => MaterialApp( ... ), ); diff --git a/README_CN.md b/README_CN.md index 6b37d5d..8416ba1 100644 --- a/README_CN.md +++ b/README_CN.md @@ -58,7 +58,7 @@ class MyApp extends StatelessWidget { return ScreenUtilInit( designSize: Size(360, 690), allowFontScaling: false, - child: MaterialApp( + builder: () => MaterialApp( ... ), ); diff --git a/README_PT.md b/README_PT.md index cccb25c..ad983fc 100644 --- a/README_PT.md +++ b/README_PT.md @@ -54,7 +54,7 @@ class MyApp extends StatelessWidget { return ScreenUtilInit( designSize: Size(360, 690), allowFontScaling: false, - child: MaterialApp( + builder: () => MaterialApp( ... ), ); diff --git a/example/lib/main.dart b/example/lib/main.dart index 18b58fd..43d2dcd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { return ScreenUtilInit( designSize: Size(360, 690), allowFontScaling: false, - child: MaterialApp( + builder: () => MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter_ScreenUtil', theme: ThemeData( diff --git a/example/lib/main_zh.dart b/example/lib/main_zh.dart index fb932f0..4eb8d0a 100644 --- a/example/lib/main_zh.dart +++ b/example/lib/main_zh.dart @@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { return ScreenUtilInit( designSize: Size(750, 1334), allowFontScaling: false, - child: MaterialApp( + builder: () => MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter_ScreenUtil', theme: ThemeData( diff --git a/lib/screenutil_init.dart b/lib/screenutil_init.dart index 29aec80..50a0631 100644 --- a/lib/screenutil_init.dart +++ b/lib/screenutil_init.dart @@ -5,13 +5,13 @@ import 'screenutil.dart'; class ScreenUtilInit extends StatelessWidget { /// A helper widget that initializes [ScreenUtil] ScreenUtilInit({ - required this.child, + required this.builder, this.designSize = ScreenUtil.defaultSize, this.allowFontScaling = false, Key? key, }) : super(key: key); - final Widget child; + final Widget Function() builder; /// The [Size] of the device in the design draft, in dp final Size designSize; @@ -31,7 +31,7 @@ class ScreenUtilInit extends StatelessWidget { allowFontScaling: allowFontScaling, ); } - return child; + return builder(); }, ); }