当我向卡片添加图像时,卡片顶部的半径会被覆盖.我怎么才能解决这个问题呢?

当我向卡片添加图像时,卡片顶部的半径会被覆盖.我怎么才能解决这个问题呢?

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primarySwatch: Colors.yellow),
      home: Scaffold(
          backgroundColor: Colors.grey[200],
          appBar: AppBar(title: Text('Demo'),),
          body: SizedBox(
              height: 310.0,
              child: Card(
                elevation: 3.0,
                color: Colors.white,
                margin: EdgeInsets.all(8.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    SizedBox(height: 0.0,),
                    Image.network('https://img.zcool.cn/community/012157578c405f0000012e7e69e7cd.jpg@1280w_1l_2o_100sh.jpg'),
                    SizedBox(height: 16.0,),
                    Row(
                      children: <Widget>[
                        SizedBox(width: 16.0,),
                        Text('素雪', style: Theme.of(context).textTheme.headline,),
                        SizedBox(width: 16.0,),
                        Text('吉时已到', style: Theme.of(context).textTheme.subhead,),
                      ],
                    ),
                    SizedBox(height: 16.0,),
                  ],
                ),
              ))),
    );
  }
}

这是渲染

enter image description here

推荐答案

卡片可以设置为clipBehavior:

Card(
      clipBehavior: Clip.antiAliasWithSaveLayer, ...

或者你可以把你的图像用ClipRRect个字母包装起来

ClipRRect(
  borderRadius: BorderRadius.vertical(top: Radius.circular(4.0)),
  child: Image.network(...),
)

Flutter相关问答推荐

ListTile未正确显示在flutter中

如何刷新future 的构建器时,没有OBS变量的内部在Ffltter?

在fltter_widget_from_html中启动url

FCM通知显示两次通知(&A)

Android Studio中的Ffltter&;Couchbase:进程C:/Program Files/Git/bin/bash以非零退出值35结束

如何将Xpriter代码页更改为代码页27?

如何在用Ffltter成功登录后重定向下一页?

在Flutter 中每次点击按钮时都很难调用自定义函数

设置Flutter 中的ListView.Builder()的最小高度

如何翻转这种剪刀设计

如何在 Flutter 中创建具有渐变背景色的自定义 Snackbar?

尽管我的 url 链接正确,但 ArgumentError(无效参数:URI 文件中未指定主机:///)错误

没有为类型 'Widget' 定义运算符 '[]' .try 定义运算符[]

如何从列表中更新provider变量:Flutter列表和Provider优化指南

我可以在列表图块下方添加其他小部件吗

如何从sibling ChildWidgetB 触发 ChildWidgetA 中的操作

Flutter:为什么我的 listTile colored颜色 被容器 colored颜色 覆盖了?

出现错误;运算符[]不是为对象类型定义的?功能()'

如何让多个图标转到不同的网址

在Flutter 中将数字转换为印度文字样式