屏幕溢出

Screen Overflow

我正在构建一个 flutter 应用程序 我已经设计了 UI 和所有但一旦我倾斜屏幕或使用 device_preview 更改设备类型,它就没有响应,整个事情就变成了一团糟。我已经在 youtube 上查看了几个视频,但它不起作用。 我需要帮助

您可以使用

来改变方向
  1. OrientationBuilder 小部件,在此小部件中,您将传递 'context' 和 'orientation' 然后检查纵向模式的方向 == Orientation.portrait 和横向模式的 Orientation.landscape 并根据检查

    构建你 UI

    方向生成器( 建设者:(背景,方向){ return容器( child:Text('any text'), height:orientation == Orientation.portrait) ? 'build portrait ui' : 'build landscape ui'; }, );

  2. 或使用 MediaQuery.of(context).orientation == Orientation.portrait 进行纵向检查,反之亦然。