Skip to content

Update devicePixelRatio in onMetricsChanged#17

Open
jimgerth wants to merge 1 commit intoominibyte:masterfrom
jusst-engineering:update-pixel-ratio
Open

Update devicePixelRatio in onMetricsChanged#17
jimgerth wants to merge 1 commit intoominibyte:masterfrom
jusst-engineering:update-pixel-ratio

Conversation

@jimgerth
Copy link
Copy Markdown

@jimgerth jimgerth commented May 9, 2023

Previously the devicePixelRatio was only set once at initialization, when it possibly was not available yet. This could lead to a wrong device type detection (e.g. a OnePlus Nord was reliably detected to be a tablet when running a Flutter app in release mode). Since the devicePixelRatio can change with an onMetricsChanged call, update the static devicePixelRatio variable in that callback to fix the device type detection.

Previously the devicePixelRatio was only set once at initialization,
when it possibly was not available yet. This could lead to a wrong
device type detection (e.g. a OnePlus Nord was reliably detected to be a
tablet when running a Flutter app in release mode). Since the
devicePixelRatio can change with an onMetricsChanged call, update the
static devicePixelRatio variable in that callback to fix the device type
detection.

Signed-off-by: Jim Gerth <jgerth@jusst.de>
@jimgerth
Copy link
Copy Markdown
Author

jimgerth commented May 9, 2023

This could possibly fix #16, someone with that device would have to check, though.

@jimgerth
Copy link
Copy Markdown
Author

jimgerth commented May 9, 2023

@ominibyte It would be awesome, if you could take a quick look at this, as it fixes some devices being wrongly detected, especially in release mode. Maybe you even have time to do a release to pub.dev with the fix :)

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 this pull request may close these issues.

1 participant