【问题标题】:Rotating an entire canvas by 90 degree in Flutter在 Flutter 中将整个画布旋转 90 度
【发布时间】:2020-10-13 02:05:55
【问题描述】:

我已经用 CustomPainter (foregroundPainter) 在 Flutter 中绘制了一个图像。在某些屏幕中,我想将整个画布的图像旋转 90 度。可能吗?谁能给我看一段代码?

谢谢

苏迪尔

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    尝试使用RotatedBox 小部件。

    RotatedBox(
      quarterTurns: 1,
      child: Text("Your widget")
    )
    

    【讨论】:

      【解决方案2】:

      选项 1:

      您可以使用 Transform.rotate 来旋转小部件。

      旋转了 90˚ (π/2)

      Widget build(BuildContext context) {
         return Transform.rotate(angle: math.pi / 2, child: Text("Text"),);
      }
      

      选项 2:如果你想旋转 90、180 或 270 度,你可以使用 RotatedBox

      RotatedBox(
        quarterTurns: 1,
        child: new Text("My Text")
      )
      

      【讨论】:

        猜你喜欢
        • 2016-06-29
        • 2017-10-19
        • 2020-08-29
        • 1970-01-01
        • 2015-10-22
        • 2011-03-22
        • 2014-07-23
        • 2019-08-23
        • 2015-03-22
        相关资源
        最近更新 更多