首页 > 解决方案 > 如何在颤动中将容器绘制在屏幕宽度之外?

问题描述

如何创建一个带有圆角的容器,如下所示?我尝试使用宽度大于屏幕宽度的容器。但这将它限制在屏幕内。我尝试使用溢出框,但也无法获得相同的结果。我不想使用 clipRect 来制作这个,因为我想在角落应用动画。

必需的

编辑:添加了带有结果的容器片段以消除疑虑

Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.black,
  body: Align(
    alignment: Alignment.bottomCenter,
    child: Container(
      height: 500,
      decoration: BoxDecoration(
          color: Colors.green, borderRadius: BorderRadius.circular(500)),
    ),
  ),
);
}

结果

标签: flutterdart

解决方案


通过使用比例转换,我设法得到了与我想要的相似的东西。不过希望看到不同的方法。

Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.black,
  body: Align(
    alignment: Alignment.bottomCenter,
    child: Transform.scale(
      scale: 1.7,
      child: Container(
        height: 400,
        decoration: BoxDecoration(
            color: Colors.green, borderRadius: BorderRadius.circular(200)),
      ),
    ),
  ),
);
}

在此处输入图像描述


推荐阅读