首页 > 解决方案 > Flutter - 摆脱 iOS 上的阴影

问题描述

我有一个 Flutter 应用程序,我正在 iOS 上对其进行测试。我发现下图有阴影(和填充) - 下图。主要问题是左右填充。

有人知道如何摆脱它吗?

代码:

return Row(
  mainAxisAlignment: MainAxisAlignment.center,
  children: <Widget>[
    roundedImage("assets/images/avatar.png"),
    Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text("XXXXXX",
              style: Theme.of(context)
                  .textTheme
                  .display2
                  .copyWith(fontSize: 20.0)),
          Text("YYYYY",
              style: Theme.of(context)
                  .textTheme
                  .display4
                  .copyWith(fontSize: 14.0)),
        ]),
    Text("ZZZZZ",
        style: Theme.of(context)
            .textTheme
            .display4
            .copyWith(fontSize: 16.0, fontWeight: FontWeight.normal))
  ],
);


 Widget roundedImage(String path) {
    return Material(
     shape: CircleBorder(),
     color: Colors.transparent,
     child: Image.asset('assets/images/xxx.png', width: imageSize, height: 
     imageSize)
 );

图片: 头像有影子

标签: androidiosflutterdropshadow

解决方案


如果我没记错的话,你可以使用Row小部件的属性来做到这一点。使用mainAxisSize: MainAxisSize.min,从两侧删除填充。

Widget roundedImage(String path) {
    return CircleAvatar(
      backgroundImage: AssetImage("images/c1.jpeg"),
      radius: 50.0,
    );
  }

推荐阅读