【问题标题】:Flutter - get rid of shadow on iOSFlutter - 摆脱 iOS 上的阴影
【发布时间】:2018-10-20 10:48:46
【问题描述】:

我有一个 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)
 );

图片:

【问题讨论】:

    标签: android ios flutter dropshadow


    【解决方案1】:

    这不会消除阴影,但遮盖阴影的好方法是将shadowColor 更改为透明。

    这就是它的样子;

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

    【讨论】:

    • 对我没有帮助,它是一样的。这似乎是默认行为。
    • 对不起,Stepan,但我现在很忙,所以我可能没有时间研究这个。在那之前,我希望你能解决这个问题
    • 实际上问题出在从 Sketch 导入文件。
    【解决方案2】:

    如果我没记错的话,你可以使用 Row 小部件的属性来做到这一点。使用 ma​​inAxisSize: MainAxisSize.min, 去除两边的填充。

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

    【讨论】:

    • 我想从图像中删除填充(阴影)
    • 我更新了我的答案,请查看。如果这不起作用,请添加您的图片。
    最近更新 更多