add Get.isLandscapeLeft and Get.isLandscapeRight #899
martin-robert-fink
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Flutter does not support landscapeLeft and landscapeRight. There is a plugin, but honestly, I wasn't impressed. Since I'm a big Get user, I thought adding these orientations to Get would be the best/right place. For now, I've solved this problem (only on iOS) by doing a platform call. I'm including (for completeness) my Dart/Flutter and Swift code in the off chance it would be useful.
If you're using a notched iPhone (iPhone X and above), your UI will/should build differently depending on the location of the notch.
My plan was to also enhance OrientationBuilder, but so far, this has solved my problem without the need to do that. OrientationBuilder gives me Orientation.landscape, then I check Left/Right with my code below.
The code below only returns the orientation. It should be obvious that I can add the convenience boolean return functions isLandscapeLeft/Right but I wanted to keep the code simple.
Here is the dart/flutter side (file name: native_orientation.dart)
Here is the Swift side (File name: AppDelegate.swift)
Beta Was this translation helpful? Give feedback.
All reactions