【问题标题】:Image with rounded bottom corners带有圆底角的图像
【发布时间】:2021-05-13 20:02:45
【问题描述】:

我正在尝试为图像添加底部圆角。我将图像包裹在 ClipRRect 中,并给它一个边框半径。以下是我能够做到的:Image with border radius

但是,我希望图像看起来像这样: enter image description here

下面是我的代码:

AnimatedContainer(
        duration: Duration(milliseconds: 150),
        curve: Curves.easeIn,
        width: width,
        height: imageHeight * height,
        child: ClipRRect(
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(100),
            bottomRight: Radius.circular(100),
          ),
          child: Image.asset(
            'assets/images/bg_login.jpg',
            fit: BoxFit.cover,
          ),
        ),
      ),

【问题讨论】:

标签: image flutter flutter-layout rounded-corners


【解决方案1】:

试试这个:

         Container(
              height: MediaQuery.of(context).size.height * 0.5,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.elliptical(
                      MediaQuery.of(context).size.width * 0.5, 45.0),
                  topRight: Radius.elliptical(
                      MediaQuery.of(context).size.width * 0.5, 45.0),
                ),
                image: DecorationImage(
                  fit: BoxFit.cover,
                  image: AssetImage("images.jpg"),
                ),
              ),
            )

这也适用于动画容器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-10
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    相关资源
    最近更新 更多