简体   繁体   English

Flutter 禁用方向更改 animation 并在特定小部件上使用自定义 animation?

[英]Flutter disable orientation change animation and use custom animation on specific widgets?

is it possible to disable the rotation animation on device orientation change, and instead react to the orientation change with my own animation?是否可以在设备方向更改时禁用旋转 animation,而是用我自己的 animation 对方向更改做出反应?

For example, when orientation changes I don't want to rotate the whole screen, only a few control button widgets.例如,当方向改变时,我不想旋转整个屏幕,只有几个控制按钮小部件。

Yes, you can block orientation changes on the device using:是的,您可以使用以下方法阻止设备上的方向更改:

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

This could be added into the initState on a particular page (then change on deactivate()), or before you even add a WidgetsApp to make it lock in from the beginning.这可以添加到特定页面的 initState 中(然后在 deactivate() 上进行更改),或者在您添加 WidgetsApp 以使其从头开始锁定之前。 However, detecting orientation change afterwards to do what you're looking for does not exist yet.但是,之后检测方向变化来做你正在寻找的事情还不存在。 This is something I've brought up in the flutter github repository since it's something I'd like as well.这是我在flutter github 存储库中提出的,因为它也是我想要的。 There is a package that I think might allow this to work if you put some elbow grease into it but I haven't gotten to trying it yet.一个 package ,我认为如果你在其中加入一些肘部润滑脂,它可能会起作用,但我还没有尝试过。

With features such as single codebase and custom interface you can restrict rotate the whole screen and you can able to do only a few control button widgets.借助单一代码库和自定义界面等功能,您可以限制旋转整个屏幕,并且您只能执行几个控制按钮小部件。 Please ask any experience Mobile Developers who has expertise on ios and Android they will provide you perfect solutions.请询问任何具有 ios 和 Android 专业知识的移动开发人员,他们将为您提供完美的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM