How can I restrict the app orientation on flutter?
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown])
I've tried this code but it doesn't work out.
What you tried works, actually. However, it is not forcing the orientation, it is merely preferring it. That means, for example, that if you try to set your orientation to landscape with
SystemChrome.setPreferredOrientations([DeviceOrientation.landscape])
Flutter will not rotate the orientation, but if you rotate your device from portrait to landscape, then the app orientation will be locked to landscape.
If you want Flutter to programatically rotate the orientation, forcing it instead of preferring it, consider using the auto_orientation package.
After importing the package you can use AutoOrientation.landscapeAutoMode();
to lock the orientation to landscape.