-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work if using SystemChrome.setPreferredOrientations #17
Comments
Have you tried with useSensor:true? |
I haven't, but suppose that should work as then it doesn't rely on the OS level processes, but I would have expected things to work without having to rely on the sensors as well. I would have rather wanted to just rely on the OS level configuration change that when the landscape layout rotates from right side up to left side up I could also rotate my camera preview. Using in built sensors logic means the layout and the preview would use entirely different logic to detect when to rotate and thus there's greater change for these to be out of sync. |
Wow, I see. It seems to be simply impossible to detect configuration changes from landscape to reverse landscape on Android. The broadcast is not emitted, Maybe the readme could be revised a bit to make this more clear and how the sensory thing fixes this? Also, at least to me it is quite unexpected that even though my orientation is locked to landscape, plugin still reports all orientations and also has to do it's own calculations which may or may not be in sync with what the OS thinks the orientation is. I would rather see this method being applied: |
Yeah unfortunately a lot of android things just check landscape vs portrait and so aren't that useful. Essentially the reason I made the app the way I did is that I wanted people to be able to detect whether the app window rotates to landscape right vs left - the main reason was to be able to rotate a camera preview back to the right orientation which only needs to be done when the 'window' actually rotates. I've actually never tried this out with an app that doesn't allow portrait though, so that's interesting. I would expect the plugin to still report a change so this does actually sound like a bug. The reason for the "sensor" would be to make an app like Youtube for example - even when have your app locked to portrait, when you play a video it fullscreens/switches to the right orientation. I'd have to do some testing of the method you've proposed, because as you said it'll have different behaviour. I'd need to check that it doesn't report orientations that aren't allowed (i.e. if you set the preferred orientations to LandscapeLeft and LandscapeRight, I don't want to be reporting back PortaitUp). And there's the added fun of what happens on a phone with autorotate enabled vs not enabled. But if it doesn't report incorrect orientations, that would actually be a good change to the plugin and I'd be happy to accept a PR (or I'll take a look at some point, but don't count on it being in the next couple days). If it does report disallowed orientations anyways, I still wouldn't be opposed to a PR, but I'd want to either put it behind a flag like useSensor so as not to change the current behaviour, or maybe use this method in conjunction with ConfigurationChanged so as to only report changes from one landscape to the other. |
@rmtmckenzie here's something I cooked up: Maybe you'd like to do something like this? |
What about the "Lock orientation" button? I could not find any solution for that. Sensors continue working if this button is enabled on both platforms. There is no API for getting its value. |
We're limit the preferred orientations to just landscapes. However, we'd like to show a camera preview and order to be able to rotate it properly we'd need to know if the device is in landscape right or left mode. This plugin would solve the problem, but it doesn't work if we enforce landscape modes using
This is happening at least with:
Here's a minima repro with freshly created flutter project
https://github.com/timolehto/flutter_native_orientation_with_preferred_orientations
The text was updated successfully, but these errors were encountered: