只是想知道我们如何在抖动中显示横向和纵向的不同布局。在适用于Android的Native中,我们只创建layout
和layout-land
文件夹,并将xml文件放在该文件夹中,系统将自动检测方向的适当布局。任何扑扑的帮助将不胜感激。谢谢
[使用官方小部件,例如文档说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,
);
},
);