LastMonopoly / scaled_app

Scale the entire UI design proportionally, useful when your UI design is fixed-width.
https://pub.dev/packages/scaled_app
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

MediaQuery still necessary? #10

Closed xErik closed 10 months ago

xErik commented 10 months ago

Flutter (Channel stable, 3.13.2)

Thank you for the package, it works very well in my case.

I initialize the package as follows:

final widgetsBinding = ScaledWidgetsFlutterBinding.ensureInitialized(
  scaleFactor: (deviceSize) {
    const double widthOfDesign = 360;
    return deviceSize.width / widthOfDesign;
  },
);

But the code below seems not to be necessary when developing using local Chrome. Everything is already correctly scaled.

MediaQuery(
        data: MediaQuery.of(context).scale(),
        child: Scaffold( ... )
)

Is that just a local quirk and is the code indeed necessary? Or is that the legacy way of using the package? Or did I misread the docs and this code was never necessary?

Thanks you!

LastMonopoly commented 10 months ago

Hi @xErik If u use mediaQueryData in your app, then please scale ur mediaQueryData on top of your app Otherwise, MediaQuery.of(context) will give u the original MediaQueryData before scaling

xErik commented 10 months ago

Thank you, I believe I understand.

Only in case I use my own MediaQuery, I have to use this construct to get the overall scaling right:

MediaQuery(
        data: MediaQuery.of(context).scale(),
        child: Scaffold( ... )
)

Maybe that would be a good point for the documentation?

Thank you!