flutter_device_type icon indicating copy to clipboard operation
flutter_device_type copied to clipboard

Update devicePixelRatio in onMetricsChanged

Open jimgerth opened this issue 2 years ago • 2 comments

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.

jimgerth avatar May 09 '23 14:05 jimgerth

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

jimgerth avatar May 09 '23 14:05 jimgerth

@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 :)

jimgerth avatar May 09 '23 14:05 jimgerth