gpt4 book ai didi

flutter - 如何禁用 flutter web 的横向模式?

转载 作者:行者123 更新时间:2023-12-05 05:44:14 25 4
gpt4 key购买 nike

我正在尝试为 flutter web 上的手机用户禁用横向模式。我已经使用这段代码来禁用它,嗯,当我将项目作为应用程序运行时它可以工作,但它不适用于 Web 项目。

  Widget build(BuildContext context) => ResponsiveSizer(
builder: (context, orientation, screenType) {
if (screenType == ScreenType.mobile) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
}

return MaterialApp(
title: 'App Title',
debugShowCheckedModeBanner: false,
theme: AppTheme.lightTheme,
home: const HomePage(),
);
},
);

知道如何实现吗?

最佳答案

您不能禁用 web 的横向模式,这不是您可以控制的。

作为网络应用程序,您必须为浏览器窗口的各种尺寸做好准备。在桌面上,用户可以将 Chrome 或 Safari 调整为他们想要的任何大小。对于移动设备,当他们将手机切换为横屏模式时,浏览器应用会使用不同的浏览器窗口大小重新呈现您的网页。

我建议您专注于让您的 Web 应用更具响应性。

关于flutter - 如何禁用 flutter web 的横向模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71636620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com