简体   繁体   English

Flutter 显示裁剪的小部件

[英]Flutter displaying cropped widgets

I would like to paint widgets outside the canvas and display only cropped portion ie., the screen's size or my own size and I want to do this dynamically.我想在 canvas 之外绘制小部件并仅显示裁剪部分,即屏幕尺寸或我自己的尺寸,我想动态地执行此操作。 Eg: sample img例如:样本 img

I was able to do this by using我能够通过使用来做到这一点

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,
            ),
          ),
        ),
      ),
    )

But using this setup allows me only to scale the widget to 3x since the alignment coordinates have only 3 positions along one axis.但是使用此设置仅允许我将小部件缩放到 3 倍,因为 alignment 坐标沿一个轴只有 3 个位置。 I want to be able to scale the widget to nx and display any of the portion.我希望能够将小部件缩放到 nx 并显示任何部分。 Pls help.请帮忙。

Found the solution, used Alignment(x,y) to scale and position the widget;)找到了解决方案,使用 Alignment(x,y) 缩放和 position 小部件;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM