I need to make resolution resolution-aware images (BitmapDescriptor)
static Future<BitmapDescriptor> makeBitmapDescriptor(
String path, BuildContext context) {
return BitmapDescriptor.fromAssetImage(
ImageConfiguration(devicePixelRatio: MediaQuery.of(context).devicePixelRatio,
path,
);
}
& for that I need the devicePixelRatio, is there a way to get it without the BuildContext
& MediaQuery.of(context).devicePixelRatio
?
CodePudding user response:
You can use fromWindow
like this:
MediaQueryData.fromWindow(WidgetsBinding.instance.window).devicePixelRatio;