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

577

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.

Share:
577
Hontoni
Author by

Hontoni

Updated on December 14, 2022

Comments

  • Hontoni
    Hontoni over 1 year

    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.