如何在抖动中显示横向和纵向的布局

问题描述 投票:0回答:1

只是想知道我们如何在抖动中显示横向和纵向的不同布局。在适用于Android的Native中,我们只创建layoutlayout-land文件夹,并将xml文件放在该文件夹中,系统将自动检测方向的适当布局。任何扑扑的帮助将不胜感激。谢谢

android ios flutter dart flutter-layout
1个回答
1
投票

[使用官方小部件,例如文档说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,
    );
  },
);
© www.soinside.com 2019 - 2024. All rights reserved.