Skip to content
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

Wrong MediaQuery Size #383

Closed
vatsaltanna-simformsolutions opened this issue Dec 6, 2022 · 6 comments · Fixed by #450
Closed

Wrong MediaQuery Size #383

vatsaltanna-simformsolutions opened this issue Dec 6, 2022 · 6 comments · Fixed by #450

Comments

@vatsaltanna-simformsolutions

Description
Widget book device uses web window MediaQuery values instead of device logical size.

Steps To Reproduce
Print MediaQuery.of(context).size in any of the widget used in widget book. you will receive wrong size there it will be web window size instead of device frame size.

Expected Behavior
MediaQuery.of(context).size should return device frame size instead of web window size.

@shigomany
Copy link

shigomany commented Dec 7, 2022

It's related for #347, if this is fixed, then this will be solved

@vatsaltanna
Copy link

I am not sure if that's related.

Reason : There is support of media query data from renderingState.deviceFrameBuilder but it is getting override by renderingState.appBuilder as renderingState.appBuilder uses MaterialApp.router which has it's own MediaQuery data of web window.

@shigomany
Copy link

I am not sure if that's related.

Reason : There is support of media query data from renderingState.deviceFrameBuilder but it is getting override by renderingState.appBuilder as renderingState.appBuilder uses MaterialApp.router which has it's own MediaQuery data of web window.

You're right I corrected the link to the issue

@roblframpton
Copy link

I am also suffering with this issue. For example, I am finding that MediaQuery.of(context).size.height always reports 800 logical pixels, regardless of the device. This is clearly wrong - there are 38 logical pixels in one centimetre, implying that every device is 21cm high, even small devices such as the iPhone SE 2016. This is annoying because I'd like to use Widgetbook to preview my page layout on different devices using media queries, but I always get the layout for large devices due to this bug.

@vatsaltanna
Copy link

Hi @roblframpton , There is a workaround for it. you can use the prerelease version of the widgetbook(widgetbook: ^3.0.0-beta.7) for now which solves this issue but there are breaking changes in that version specific to the structure of widget tree so you can refer the widgetbook example to solve those errors in prerelease version. FYI in the current version it is actually returning web browser size instead of the device size.

@roblframpton
Copy link

roblframpton commented Jan 25, 2023

Thanks @vatsaltanna. I'll probably just wait for version 3 to be released and stable, for now I am using LayoutBuilder to get a similiar effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants