Last active
July 29, 2019 05:29
-
-
Save shishirthedev/50a50f7dfb1237286e9942124bc02b69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Way 01: | |
--------------------------------------------------------- | |
import 'package:flutter/services.dart'; | |
void main() { | |
SystemChrome.setPreferredOrientations( | |
[DeviceOrientation.portraitUp,DeviceOrientation.portraitDown]) | |
.then((_) { | |
runApp(MyApp()); | |
}); | |
} | |
{ Note: The 'setPreferredOrientations' method returns a Future object. that's why you | |
shall wait until it's available and then move on with the application. Hence, | |
there shall be used 'then' method } | |
Way 02: | |
--------------------------------------------------------- | |
For Android: | |
Open android/app/src/main/AndroidManifest.xml and add | |
android:screenOrientation="portrait" | |
in your Main Activity | |
For iOS: | |
Open your project with xcode and restrict orientation for Potrait mode. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment