Committed by
GitHub
don't use future builder when not ensureScreenSize (#517)
Showing
1 changed file
with
15 additions
and
3 deletions
@@ -73,7 +73,7 @@ class ScreenUtilInit extends StatefulWidget { | @@ -73,7 +73,7 @@ class ScreenUtilInit extends StatefulWidget { | ||
73 | this.splitScreenMode = false, | 73 | this.splitScreenMode = false, |
74 | this.minTextAdapt = false, | 74 | this.minTextAdapt = false, |
75 | this.useInheritedMediaQuery = false, | 75 | this.useInheritedMediaQuery = false, |
76 | - this.ensureScreenSize, | 76 | + this.ensureScreenSize = false, |
77 | this.responsiveWidgets, | 77 | this.responsiveWidgets, |
78 | this.fontSizeResolver = FontSizeResolvers.width, | 78 | this.fontSizeResolver = FontSizeResolvers.width, |
79 | }) : super(key: key); | 79 | }) : super(key: key); |
@@ -83,7 +83,7 @@ class ScreenUtilInit extends StatefulWidget { | @@ -83,7 +83,7 @@ class ScreenUtilInit extends StatefulWidget { | ||
83 | final bool splitScreenMode; | 83 | final bool splitScreenMode; |
84 | final bool minTextAdapt; | 84 | final bool minTextAdapt; |
85 | final bool useInheritedMediaQuery; | 85 | final bool useInheritedMediaQuery; |
86 | - final bool? ensureScreenSize; | 86 | + final bool ensureScreenSize; |
87 | final RebuildFactor rebuildFactor; | 87 | final RebuildFactor rebuildFactor; |
88 | final FontSizeResolver fontSizeResolver; | 88 | final FontSizeResolver fontSizeResolver; |
89 | 89 | ||
@@ -133,7 +133,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -133,7 +133,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
133 | } | 133 | } |
134 | 134 | ||
135 | Future<void> _validateSize() async { | 135 | Future<void> _validateSize() async { |
136 | - if (widget.ensureScreenSize ?? false) return ScreenUtil.ensureScreenSize(); | 136 | + if (widget.ensureScreenSize) return ScreenUtil.ensureScreenSize(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void _markNeedsBuildIfAllowed(Element el) { | 139 | void _markNeedsBuildIfAllowed(Element el) { |
@@ -171,6 +171,18 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -171,6 +171,18 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
171 | 171 | ||
172 | if (mq == null) return const SizedBox.shrink(); | 172 | if (mq == null) return const SizedBox.shrink(); |
173 | 173 | ||
174 | + if (!widget.ensureScreenSize) { | ||
175 | + ScreenUtil.configure( | ||
176 | + data: mq, | ||
177 | + designSize: widget.designSize, | ||
178 | + splitScreenMode: widget.splitScreenMode, | ||
179 | + minTextAdapt: widget.minTextAdapt, | ||
180 | + fontSizeResolver: widget.fontSizeResolver, | ||
181 | + ); | ||
182 | + | ||
183 | + return widget.builder?.call(context, widget.child) ?? widget.child!; | ||
184 | + } | ||
185 | + | ||
174 | return FutureBuilder<void>( | 186 | return FutureBuilder<void>( |
175 | future: _screenSizeCompleter.future, | 187 | future: _screenSizeCompleter.future, |
176 | builder: (c, snapshot) { | 188 | builder: (c, snapshot) { |
-
Please register or login to post a comment