Skip to content

Instantly share code, notes, and snippets.

@bdiegel
Created July 31, 2018 00:30
Show Gist options
  • Save bdiegel/81d0f4b7c13212048d4bcb15cb202de6 to your computer and use it in GitHub Desktop.
Save bdiegel/81d0f4b7c13212048d4bcb15cb202de6 to your computer and use it in GitHub Desktop.
flutter - device pixel ratio
queryData = MediaQuery.of(context);
double devicePixelRatio = queryData.devicePixelRatio;
'size (pixels): w=${queryData.size.width * devicePixelRatio}, h=${queryData.size.height * devicePixelRatio}'
'devicePixelRatio: $devicePixelRatio'
'size: w=${queryData.size.width}, h=${queryData.size.height}'
'textScaleFactor: w=${queryData.textScaleFactor}'
From example:
https://stackoverflow.com/questions/44173641/how-can-flutter-handle-dpi-text-and-image-size-differences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment