How to show different layout for landscape and portrait in flutter

594

Use official widget like docs says https://flutter.dev/docs/cookbook/design/orientation

OrientationBuilder(
  builder: (context, orientation) {
    return GridView.count(
      // Create a grid with 2 columns in portrait mode,
      // or 3 columns in landscape mode.
      crossAxisCount: orientation == Orientation.portrait ? 2 : 3,
    );
  },
);
Share:
594
Dipankar Baghel
Author by

Dipankar Baghel

A Result oriented Mobile application developer with 8+ yrs. of experience. Hands on exposure in Android, Java, Kotlin, IOS, Swift, Xamarin, Spring boot, Hibernate, MySql, Python, Django, Web Services, REST, JSON.

Updated on December 15, 2022

Comments

  • Dipankar Baghel
    Dipankar Baghel over 1 year

    Just wanted to know how we can show different layout for landscape and portrait in flutter. In Native for android we just create layout and layout-land folder and put xml files there and system will automatically detect the appropriate layout for orientation. Any help on flutter would be appreciated. Thanks