When I am rotating screen its rotates camera along with the screen, so I am getting Inverted camera screen.
return new AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: new CameraPreview(controller),
);
In Flutter we have SystemChrome. setPreferredOrientation() (see documentation) to define preferred orientation. Exactly this method you can find in all those articles about setup orientation in Flutter.
You can build responsive apps using OrientationBuilder
OrientationBuilder(
builder: (context, orientation) {
return GridView.count(
// Create a grid with 2 columns in portrait mode, or 3 columns in landscape mode.
crossAxisCount: orientation == Orientation.portrait ? 2 : 3,
);
},
);
or
Orientation currentOrientation = MediaQuery.of(context).orientation;
if(currentOrientation == Orientation.portrait){
/* ... */
}
To enforce a particular orientation see this https://stackoverflow.com/a/50322184/9664127
other useful links:
https://flutter.io/cookbook/design/orientation/
https://docs.flutter.io/flutter/services/DeviceOrientation-class.html
https://medium.com/@kr1uz/how-to-restrict-device-orientation-in-flutter-65431cd35113
Updated
Flutter does not currently support 'orientation sides', but this plugin may help in that area https://pub.dartlang.org/packages/native_device_orientation
You can use this plugin: https://pub.dartlang.org/packages/native_device_orientation
(I'm having some issues with iOS - reporting opposite orientation, but this can be worked around)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With