Flutter change screen orientations

Screen orientation is one of best part in app. Some games always be landscape and some of business based app always be portrait orientation. 


For Portrait orientation:

WidgetsFlutterBinding.ensureInitialized(); 

  await SystemChrome.setPreferredOrientations(

    [DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]);


For Landscape orientation:

WidgetsFlutterBinding.ensureInitialized(); 

  await SystemChrome.setPreferredOrientations(

    [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);


Comments

Popular posts from this blog

Flutter Bloc - Clean Architecture

What's new in android 14?

Dependencies vs Dev Dependencies in Flutter