Search code examples
iosflutterflutter-image-picker

Fix: [Camera] Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported


I'm using the image_picker package from Flutter. The following messages are showing up when attempting to open the camera using the packages ImagePicker().pickImage() method:

[Camera] Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
[Camera] Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
[Camera] Attempted to change to mode Portrait with an unsupported device (BackAuto). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
[Camera] Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).

I'm literally simply trying to do ImagePicker().pickImage(), and this always happens for the first time of a flutter run "run" when I test the app. You tap the button calling ImagePicker().pickImage(), nothing happens for around 10 seconds, then the camera opens and the warnings are logged. This does not happen on subsequent camera opening attempts, except if you run flutter run again, which is when it again happens at the first time.

How can I fix this?

  • The solution mentioned here did not work for me.
  • Neither did this
  • Neither did this
  • Neither did setting the Supported Interface Orientations option in your Info.plist file via XCode to Portrait (bottom home button), even if you do so for all, iPhone and iPad.
  • Neither did anything indicated here, which describes exactly my issue, except that they do not mention my logs anywhere.

Note (not sure if this actually causes any trouble): I'm locking my Flutter App in portrait mode using:

void main() {
  /// Locking the device orientation in portraitUp
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
      .then((fn) {
    runApp(
      // Provider Scope 
      const ProviderScope(
        child: MyApp(),
      ),
    );
  });
}

Solution

  • Ok so no clue why the mentioned logs show up, but the delay which is the major issue upon opening the camera for the first time does not happen when you run the app using flutter run --release, so this performance problem seems to be related to common performance problems when running the Flutter App in debug mode.