Deep dive into screen orientation in Flutter
<p>The mobile application usually develops to support both portrait and landscape mode without any issue. But in some special case, you may need to set the orientation of the application to fix direction to get proper real state space to each component</p>
<p><iframe frameborder="0" height="435" scrolling="no" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FKyB4LZTCrXE8W9HqiA%2Ftwitter%2Fiframe&display_name=Giphy&url=https%3A%2F%2Fgiphy.com%2Fstickers%2Fgenies-transparent-geeryanimation-KyB4LZTCrXE8W9HqiA&image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FKyB4LZTCrXE8W9HqiA%2Fgiphy.gif&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=giphy" title="Gravity Geeryanimation Sticker by Genies for iOS & Android | GIPHY" width="435"></iframe></p>
<h1>Set the orientation in flutter</h1>
<p>First, you have to import the services package.</p>
<pre>
import 'package:flutter/services.dart';</pre>
<p>Next, you can set orientation by setting the value to setPreferredOrientations method in SystemChrome class. In the Flutter the application entry point is the main method. So you can set orientation before call the runApp method in the main method. But if you need to call a binding before the runApp method, you must call the <a href="https://api.flutter.dev/flutter/widgets/WidgetsFlutterBinding/ensureInitialized.html" rel="noopener ugc nofollow" target="_blank">ensureInitialized</a> method in WidgetsFlutterBinding class.</p>
<p><a href="https://suryadevsingh24032000.medium.com/deep-dive-into-screen-orientation-in-flutter-bc81858f2c57"><strong>Read More</strong></a></p>