How to detect landscape orientation when the device is in portrait mode and the app supports only portrait mode in flutter? - flutter

My flutter app only supports portrait mode.
However, on one screen user can take the pic using the camera plugin. Users can take the pic portrait mode or landscape mode(Without changing device orientation).
I want to display a rectangle overlay on top of the camera. So if I can detect the mobile is in landscape or portrait mode I can add x,y, height, width values according to the orientation.
I am not asking about the Orientation builder because my app only supports portrait mode.
I have read some articles about Gyrometer to detect the device orientation. But in flutter, I haven't found code examples.

Related

How to rotate device screen from landscape to portrait in tizen web application?

I am developer tizen consumer tv web app.How should i rotate the screen (toggle orientation) by code.
Please help us in this.
Let me know if you need any further information.
Lock the screen with the lockOrientation() method.
The following code snippet demonstrates how to lock the screen to a specified orientation.
screen.lockOrientation("portrait-secondary");
The method accepts the following parameter values: portrait-primary, portrait-secondary, landscape-primary, landscape-secondary, portrait, and landscape.
Note:
When using the screen orientation lock:
When the portrait value is used to lock the orientation, the orientation can change between portrait-primary and portrait-secondary. The landscape value behaves similarly.
Depending on the browser, unlocking the screen orientation may have no visual effect.
For more follow this.
You can use this code for rotate the device form Landscape to portrait .
b2bapis.b2bcontrol.setMenuOrientation("DEGREE_90",onSuccessSettingMenuOrientation,onErrorSettingMenuOrientation);
b2bapis.b2bcontrol.setSourceOrientation("TV","DEGREE_90", onSuccessSettingOrientation, onErrorSettingOrientation);
Note: need to add privileges in config.xml

Landscape orientation in iPad Pro

I have created a program with a cover image which changes depending on the orientation: it displays a portrait image in portrait mode, and a landscape image in landscape mode. Everything is working fine in every iPhone & iPad simulators, but not in the iPad Pro simulator. Actually, the landscape mode does work, but instead of displaying the landscape cover image, it just adapts the height of the Portrait cover image to the new height in Landscape mode. I don't own an iPad Pro yet, so I don't know if it comes from the iPad Pro or the simulator. Does anyone have encountered this kind of problem? Is there some code to add specifically for iPad Pro?
Without seeing your project, you might need to force your app to use the full screen. In the app target, try checking "Requires Full Screen" is enabled.

Unity app with different screen orientations

I'm developing a game that runs on both mobile phones and tablets.
Currently I'm using only the Portrait orientation for all devices but the portrait orientation looks better on phones meanwhile landscape orientation looks better on tablets.
I set "Portrait" option in the Unity's Player Settings > Resolution and Presentation > Default Orientation but I would like to provide a landscape layout for tablets (without affecting phones).
How I can I do that? Is there any why to programmatically set the Screen orientation when the application starts?
You can try Screen.Orientation
In the Start (or Awake) method of a MonoBehaviour that is added to the stage call:
Screen.Orientation = ScreenOrientation.LandscapeRight
Now you just need to check if the device is tablet or phone, I don't know any way out of the box to do this, but you can check the aspect ratio and base your decision on this.
You can check the aspect ratio by getting Screen.width and Screen.height.

Launch splash screen in Landscape mode for iPhone 5

Our universal application is in Landscape mode only. We need to add a splash screen for iPhone 4 & iPhone 5.
For iPhone 5 in Portrait we use Default-568h#2x.png. How to set a launch screen in Landscape for iPhone 5?
According to Apple's Documentation : Providing Launch Images for Different Orientations
,
Each orientation-specific launch image must include a special modifier string in its filename. The format for orientation-specific launch image filenames is as follows:
<basename><orientation_modifier><scale_modifier><device_modifier>.png
Eg :
1) Default-Portrait.png
2) Default-PortraitUpsideDown.png
3) Default-Landscape.png
4) Default-LandscapeLeft.png
5) Default-LandscapeRight.png
Note : These modifiers are supported for launch images used in iPad apps only.
So you have to change your Image according to the Orientation for iPhone 5.
Two ways to do that :
1) Rotating the Splash Image to 90 Degree.
2) Inverting the Dimensions (320 * 480 -> 480 * 320).
to provide a landscape launch image you must create the image.. and just rotate it 90 degrees in an external image editor
Very simple
make design on splash screen in landscape mode .
and just make splash screen as you do in portrait .
user automatically make phone landscape when he/she see screen is in landscape :-)
From Apple doc, landscapes launch screens are supported for iPad only.
For iPhone and iPod Touch, you need to create a portrait launch screen that can be your 90°-oriented landscape launch screen. I would apply a clockwise rotation rather than a counter-clockwise rotation (ie so that on a desktop, you need to bend your head on the right to see the image with the correct orientation).
use these macros in pch file
#if IS_iPAD
LaunchImage=iPad.png
else
LaunchImage=iPhone.png

landscape splash screen for iphone apps?

i am developing an app which supports all orientations. i need to launch the splash screen (launching image) in all orientation types. but the project summary have only one field (portrait) to set the Default.png. how will i launch the landscape splash screen on my iphone app.
ipad have some features to setup both the orientations. is their anything like that in iphone,
thank you in advance
iPhone splash screen is only Portrait. iPad has landscape too because iPad home screen auto rotates unlike iPhone's.
In order to achieve such a behavior you can make your first screen identical to the splash screen ( add the same image on the background) . So it will look like a landscaped splash screen while you are loading the resources needed for your app but you can't start the app in landscape mode.
Hope this helps.
Cheers!
Nope, according to HIG, iPhone's default orientation is portrait and launch will do only portrait mode.
Let me quote a special behaviour
From Technical Note TN2244 Launching your iPhone Application in Landscape
Except for launch images used by the iPhone 6 Plus, asset catalogs assume that all iPhone launch images are for the portrait orientation.
Therefore
Launch images for iPhone apps are always sized to match the dimensions of the screen in portrait orientation. For applications that launch into landscape orientation, you should use your preferred graphics editing software to rotate the content of the launch image while keeping the image's size consistent with a portrait launch image (height > width).
if you don't do things correctly, you can end up with a blank/white screen
The result is a blank screen during launch as the system cannot find an appropriate launch image.
Unfortunately, the document was last updated 2 years ago.
2015-05-26 Updated for Xcode 6 and iOS 8.