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

Missing scaledWidth and scaledHeight from ResponsiveBreakpointData on new version 1.0.0 #145

Open
oneshoot41 opened this issue Jun 8, 2023 · 12 comments

Comments

@oneshoot41
Copy link

In older version 0.2.0 i used to call this value with ResponsiveWrapper.of(context).scaledWidth needed by the onboarding_overlay package to be responsive (since version 3.1.0 of the package.

But in the 1.0.0 update i don't see this value anymore, only screenWidth and screenHeight are available now so my app tutorial is broken...

Is there a newer solution to get these values ? Am i missing something ?

I'd like to get them as before like this now : ResponsiveBreakpoints.of(context).scaledWidth

Thanks.

@ch-muhammad-adil
Copy link

+1 I am also facing same challenge, I am doing few computations based on these variables/values and now I can not handle it with latest version.

@ch-muhammad-adil
Copy link

ch-muhammad-adil commented Jun 22, 2023

I can clearly see in the code here it is documented but there is no work done at calculating scaled values

/// `ResponsiveWrapper.of(context).scaledWidth`.

and here

/// such as [ResponsiveBreakpointsData.scaledWidth].

@ch-muhammad-adil
Copy link

@rayliverified any help?

@mdmm13
Copy link

mdmm13 commented Jul 17, 2023

Same problem here.

@youssef-fk
Copy link

What did is that, in the MaterialApp builder function. I added something like this

if (ResponsiveBreakpoints.of(context).screenWidth <= 450) {
    return ResponsiveScaledBox(width: 400, child: child);
}

@mdmm13
Copy link

mdmm13 commented Jul 17, 2023

Thank you for the feedback. How though did you calculate scaledWidth?

@mdmm13
Copy link

mdmm13 commented Jul 24, 2023

@rayliverified, was sorry to hear you're suffering from Long Covid. Can't imagine how that's affecting your daily life.

May I ask you to weigh in briefly on how we can bypass this issue? Maybe we can fix this ourselves with a tiny bit of guidance on how to calculate the values ourselves in 1.1.0? Found some calculations in the previous versions, but not sure how to get them to work in the 1.1.0 release?

          double aspectRatio = constraints.maxWidth / constraints.maxHeight;
          double scaledWidth = width!;
          double scaledHeight = width! / aspectRatio;

          bool overrideMediaQueryData = autoCalculateMediaQueryData &&
              (mediaQueryData.size ==
                  Size(constraints.maxWidth, constraints.maxHeight));

          EdgeInsets scaledViewInsets = getScaledViewInsets(
              mediaQueryData: mediaQueryData,
              screenSize: mediaQueryData.size,
              scaledSize: Size(scaledWidth, scaledHeight));
          EdgeInsets scaledViewPadding = getScaledViewPadding(
              mediaQueryData: mediaQueryData,
              screenSize: mediaQueryData.size,
              scaledSize: Size(scaledWidth, scaledHeight));
          EdgeInsets scaledPadding = getScaledPadding(
              padding: scaledViewPadding, insets: scaledViewInsets);

@rayliverified
Copy link
Contributor

Thank you for your patience. Migration guide is up!

https://github.com/Codelessly/ResponsiveFramework/blob/master/migration_0.2.0_to_1.0.0.md

@rayliverified
Copy link
Contributor

The AutoScale functionality has been moved to ResponsiveScaledBox.

ResponsiveScaledBox will override the MediaQueryData to return the computed scaled width.
You can get the scaled width with MediaQuery.of(context).size.width.

@shrijanRegmi
Copy link

Hey @rayliverified,

What's the equivalent of ResponsiveWrapper.of(context).screenHeight in the new update?

@rayliverified
Copy link
Contributor

The MediaQueryData is updated directly whenever a ResponsiveScaledBox is used. So you can get the scaled width and height via MediaQuery.of(context).size.

This replaces the previous ScaledWidth and ScaledHeight variables.

@shrijanRegmi
Copy link

I was actually asking about screenHeight and not scaleHeight. I found it though:

ResponsiveBreakpoints.of(context).screenHeight

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

No branches or pull requests

6 participants