How to Set Landscape Orientation Mode For Flutter Application ??

· 3 min read
How to Set Landscape Orientation Mode For Flutter Application
How to Set Landscape Orientation Mode For Flutter Application

When an app is displaying in landscape orientation there is much less height available. This makes it impossible to vertically list all of our widgets as there is just not enough space for all of this. So in today’s article, we will walk through step by step process of how to Set Landscape Orientation Mode For Flutter Application.

What is Portrait Orientation ??

The portrait layout was achieved by using a single column arrangement. You’ll also notice we gave the logo a little more flex so that it gets more space than the other widgets.

How to Set Landscape Orientation Mode For Flutter Application ??

Enable forcefully

Import package: import ‘package:flutter/services.dart’; in main.dart file

Landscape mode code snippet will look like the below:

// Set landscape orientation
SystemChrome.setPreferredOrientations([
  DeviceOrientation.landscapeLeft,
  DeviceOrientation.landscapeRight,
])

So the code Snippet will look like the below:

landscape mode in flutter
landscape mode in flutter

Portrait mode:

// Set portrait orientation
SystemChrome.setPreferredOrientations([
   DeviceOrientation.portraitDown,
   DeviceOrientation.portraitUp,
])

For a portrait mode snippet will look like the below:

landscape mode in flutter
landscape mode in flutter

You can also perform the same using below code snippet.

import 'package:flutter/services.dart';

void main()  {
   WidgetsFlutterBinding.ensureInitialized();
   SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft])
   .then((_) {
    runApp(new MyApp());
  });
}

SystemChrome.setPreferredOrientations is applicable for the flutter part of the app, but it’s not a full solution. because when you launching the app – flutter is not created yet. so you should also set up orientation in the native parts.

Conclusion:

Thank you for reading!! Let us know in the comments what methods you had used previously!!

So in this article, we have been through how to set landscape orientation mode for flutter application ??

Do let us know if you need any assistance with flutter development?? we would love to assist you.

Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply