Skip to content

Instantly share code, notes, and snippets.

@peerwaya
Forked from bdiegel/Flutter MediaQuery
Created April 17, 2019 13:28
Show Gist options
  • Save peerwaya/38091f2a005f74cffe2771115cfe1fd5 to your computer and use it in GitHub Desktop.
Save peerwaya/38091f2a005f74cffe2771115cfe1fd5 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