问题:
Flutter 中设备旋转后如何布局?
解决方法:
为了监听到设备的旋转,可以使用 OrientationBuilder。 当设备旋转以后,OrientationBuilder 就会 rebuild.
new OrientationBuilder( builder: (context, orientation) { return new GridView.count( // Create a grid with 2 columns in portrait mode, or 3 columns in // landscape mode. crossAxisCount: orientation == Orientation.portrait ? 2 : 3, ); }, );