简体   繁体   中英

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?

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. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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