Flutter App Orientation Setup Portrait or Landscape Mode
Set Portrait Mode of Flutter App
Orentation depends on Flutter Service package. So first of all import the service package.
import 'package:flutter/services.dart';
Now Add this lines of code on main.dart file.
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
/* DeviceOrientation.portraitup, */
DeviceOrientation.portraitDown,
]).then((value) => runApp(MyApp()));
runApp(MyApp());
}
Set Landscape Mode of Flutter App
Now, chan this values to set your app into Landscape Mode.SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
Preview
So the codes will be look like that. Now run your app, it will now follow as you set it.In our next tutorial we will demonstrate how to change orentation by click on a button on your Flutter App. If you think this information helps you then please comments and share it with your geeky friend. Thank You