Skip to content

Commit

Permalink
推荐使用 useInheritedMediaQuery 为 false (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
naivetoby authored May 31, 2023
1 parent 1479ea4 commit 26a4b1f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/src/screenutil_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ScreenUtilInit extends StatefulWidget {
this.designSize = ScreenUtil.defaultSize,
this.splitScreenMode = false,
this.minTextAdapt = false,
this.useInheritedMediaQuery = true,
this.useInheritedMediaQuery = false,
this.scaleByHeight = false})
: super(key: key);

Expand Down Expand Up @@ -76,15 +76,17 @@ class _ScreenUtilInitState extends State<ScreenUtilInit>
wrappedInMediaQuery = true;
return data;
}
} else {
final data = MediaQuery.maybeOf(context);

if (data != null) {
return data;
}
}

return MediaQueryData.fromView(View.of(context));
}

Widget get child {
return widget.builder.call(context, widget.child);
}

_updateTree(Element el) {
el.markNeedsBuild();
el.visitChildren(_updateTree);
Expand Down Expand Up @@ -148,7 +150,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit>
widget.designSize.height
: deviceSize.width,
height: deviceSize.height,
child: child,
child: widget.builder(__context, widget.child),
),
));
},
Expand Down Expand Up @@ -176,7 +178,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit>
widget.designSize.height
: deviceSize.width,
height: deviceSize.height,
child: child,
child: widget.builder(_context, widget.child),
),
));
}
Expand Down

0 comments on commit 26a4b1f

Please sign in to comment.