如何在flutter中显示横向和纵向的不同布局

Dip*_*hel 5 android ios dart flutter flutter-layout

只是想知道如何在 flutter 中显示横向和纵向的不同布局。在 Native for android 中,我们只需创建layoutlayout-land文件夹并放置 xml 文件,系统将自动检测适当的方向布局。任何有关颤振的帮助将不胜感激。谢谢

Nav*_*idi 3

使用官方小部件,如文档所述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,
    );
  },
);
Run Code Online (Sandbox Code Playgroud)