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

Mastering API Development: Why Postman Reigns Supreme Over Swagger

What's new in android 14?

AppWrite vs Supabase vs Firebase