1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter: Enforcing an orientation doesn't work for all iOS versions?

Discussão em 'Mobile' iniciado por Stack, Novembro 4, 2024 às 08:23.

  1. Stack

    Stack Membro Participativo

    I have a problem with the orientation of the CameraPreview in flutter. It always switched to landscape mode when I turned it which also distorted the image it was recording. I did not want this, so I added the following to the main.dart:

    await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    ]);



    This fixed the problem for android but iOS was still bugging. So, I added the following to the info.plist:

    <key>UISupportedInterfaceOrientations</key>
    <array>
    <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
    <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>


    and on my iPhone iOS 11 17.6.1, this did the trick. However, on other people's iPhones (iPhone 14, 17.5.1; iPhone 13 Pro, 17.6.1) this did not solve the issue. The os is still turning the screen and thus distorting or showing the preview in a really small window at the top of the screen.

    I have to admit: I am clueless of how to proceed due to my code working on some devices and some not.

    Do you have any hint or idea?

    Much appreciated!

    Continue reading...

Compartilhe esta Página