Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set my app to landscape mode in Flutter?

I want to set my app's default orientation as landscape like when I open a game app such as clash of clans or mobile legend. How can I do that in flutter?

like image 737
Rinzin Avatar asked Oct 17 '25 10:10

Rinzin


1 Answers

Put this code in the MyApp()

  SystemChrome.setPreferredOrientations([
    DeviceOrientation.landscapeLeft,
    DeviceOrientation.landscapeRight,
  ]);

Like below:

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
      ]);
      return new MaterialApp();
    }
  }

If you want the Portrait mode then check out this answer

like image 91
ibhavikmakwana Avatar answered Oct 20 '25 23:10

ibhavikmakwana