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

pixelRatio for rendered Flutter widget should default to the device's pixel ratio #205

Open
ueman opened this issue Jan 10, 2024 · 2 comments · May be fixed by #304
Open

pixelRatio for rendered Flutter widget should default to the device's pixel ratio #205

ueman opened this issue Jan 10, 2024 · 2 comments · May be fixed by #304

Comments

@ueman
Copy link
Contributor

ueman commented Jan 10, 2024

When creating screenshot widget with

var path = await HomeWidget.renderFlutterWidget(
  const LineChart(),
  key: 'lineChart',
  logicalSize: const Size(400, 400),
  pixelRatio: 3,
);

You're able to set a pixelRatio. This should default to whatever is set in MediaQueryData.devicePixelRatio. Another way of accessing that data should be possible via the PlatformDispatcher.instance.implicitView.devicePixelRatio.

It should default to whatever the current device pixelratio is, since otherways I always have to manually set it to that value. So by doing this already inside the app, it improves the quality of life of the users.

So this

var path = await HomeWidget.renderFlutterWidget(
  const LineChart(),
  key: 'lineChart',
  logicalSize: const Size(400, 400),
  pixelRatio: PlatformDispatcher.instance.implicitView?.devicePixelRatio ?? 3,
);

becomes this

var path = await HomeWidget.renderFlutterWidget(
  const LineChart(),
  key: 'lineChart',
  logicalSize: const Size(400, 400),
);

and the screenshot of the widget is always in the correct resolution.

Additionally, I believe this piece of code

devicePixelRatio: 1.0,

should also reuse the configured pixel ratio, right?

@morningf
Copy link

I agree, this suggestion should be adopted.

@dkbast
Copy link

dkbast commented Aug 5, 2024

This would also make updating the home widget from anywhere thats not "UI" code much easier :)

ueman added a commit to ueman/home_widget that referenced this issue Oct 2, 2024
@ueman ueman linked a pull request Oct 2, 2024 that will close this issue
5 tasks
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

Successfully merging a pull request may close this issue.

3 participants