是否有可能使设备尺寸颤动?

Is it possible to get the device sizes in flutter?

我正在构建一个 flutter web 应用程序,我想知道该应用程序所在设备的宽度 运行,而不是 window。这可能吗?谢谢!

您无需访问 BuildContext 即可获取它,如下所示:

final double width = window.physicalSize.width / window.devicePixelRatio;
final double height = window.physicalSize.height / window.devicePixelRatio;

确保导入 dart:ui,而不是 html 库。