Logo-amall

Wrong MediaQuery Size

Last active 14 days ago

7 replies

6 views

  • VA

    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.

  • SH

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

  • VA

    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.

  • SH

    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

  • RO

    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.

  • VA

    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.

  • RO

    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,

Last active 14 days ago

7 replies

6 views