setAspectRatioEnabled static method
设置窗口比例调整功能的启用状态
Implementation
static Future<void> setAspectRatioEnabled(bool enabled) async {
_globalEnableAspectRatio.value = enabled;
if (MyPlatform.isDesktop) {
if (enabled) {
// 获取当前窗口大小并设置比例
final currentSize = await windowManager.getSize();
await windowManager
.setAspectRatio(currentSize.width / currentSize.height);
} else {
// 移除比例限制,设置为0表示无限制
await windowManager.setAspectRatio(0);
}
}
}