颤振显示裁剪的小部件

时间:2020-04-18 06:09:41

标签: flutter widget crop custom-painting

我想在画布外绘制小部件,并仅显示裁剪的部分,即屏幕的大小或我自己的大小,我想动态地做到这一点。 例如:sample img

我能够通过使用

来做到这一点
UnconstrainedBox(
      child: Align(
        alignment: Alignment.bottomCenter,
        child: Container(
          color: Colors.lightBlue,
          //width: MediaQuery.of(context).size.width,
          //height: MediaQuery.of(context).size.height ,
          width: _size.width,
          height: _size.height,
          child: FittedBox(
            alignment: Alignment.bottomCenter,
            fit: BoxFit.none,
            child: Container(
              width: _size.width,
              height: _size.height * 2,
              child: MyWidget,
            ),
          ),
        ),
      ),
    )

但是使用此设置只能将小部件缩放为3倍,因为对齐坐标沿一个轴只有3个位置。我希望能够将小部件缩放到nx并显示任何部分。请帮助。

1 个答案:

答案 0 :(得分:0)

找到解决方案,使用Alignment(x,y)缩放和定位小部件;)