Skip to content

推荐使用 useInheritedMediaQuery 为 false #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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