装饰图像不被BoxDecoration剪切

时间:2019-01-22 09:52:48

标签: dart flutter

为什么我不能在BoxDecoration父窗口小部件内裁剪方形png图像?我做错了什么?

enter image description here

这是我的代码:

final appLogo = Hero(
  tag: 'hero',
  child: Container(
    width: 200.0,
    height: 200.0,
    decoration: new BoxDecoration(
        shape: BoxShape.circle,
        border: Border.all(color: Colors.white, width: 1.5),
        image: DecorationImage(
          image: AssetImage('images/logo.png'),
          fit: BoxFit.fill,
        )),
  ),
);

.....

return Scaffold(
  backgroundColor: Colors.brown.shade100,
  body: Center(
    child: ListView(
      shrinkWrap: true,
      padding: EdgeInsets.only(left: 24.0, right: 24.0),
      children: <Widget>[
        appLogo,
        SizedBox(
          height: 48,
        ),
        emailField,
        SizedBox(
          height: 8.0,
        ),
        passwordField,
        SizedBox(
          height: 24.0,
        ),
        loginButton,
        forgotPButton,
      ],
    ),
  ),
);
  }
}

1 个答案:

答案 0 :(得分:0)

颤抖的github上有一个关于此问题的问题,Add Container.clipBehavior to clip to the decoration #14421

目前,您可以使用CircleAvatar来实现所需的功能。