getScreenSize method
Implementation
@override
Future<Size> getScreenSize(BuildContext? context) async {
double devicePixelRatio = 1.0;
if (context != null) {
var data = context.findAncestorWidgetOfExactType<MediaQuery>()?.data;
if (data != null) {
devicePixelRatio = data.devicePixelRatio;
}
}
var map = await methodChannel.invokeMethod<Map>('getScreenSize', {});
int width = map!["width"];
int height = map["height"];
var size = Size(width.toDouble() / devicePixelRatio, height.toDouble() / devicePixelRatio);
return size;
}