android - Flutter:图像溢出容器

我在 Flutter 中为每个事件使用 Card 来制作事件信息列表。每张牌的领先与事件有关。

我想让我的卡片成为圆角矩形,但是当我将图像放在卡片的子项内的行的子项中时,图像的角不是圆角的。

我的卡片类:

import 'package:flutter/material.dart';

class SmallEventCard extends StatefulWidget {
  final imageURL;
  final title;
  final time;
  final place;

  SmallEventCard({this.imageURL, this.title, this.time, this.place});

  @override
  _SmallEventCardState createState() => _SmallEventCardState();

}

class _SmallEventCardState extends State<SmallEventCard> {
  bool isFavorite;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    isFavorite = false;
  }

  @override
  Widget build(BuildContext context) {
    final screen = MediaQuery.of(context).size;


    return Material(
      child: SizedBox(
        height: screen.height / 7,
        child: Card(
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
          child: Row(
            children: <Widget>[
              AspectRatio(
                aspectRatio: 4 / 3,
                child: Image.network(widget.imageURL,
                  fit: BoxFit.fitHeight,
                ),
              ),
              SizedBox(
                width: 10.0,
              ),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(widget.title, 
                      style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),maxLines: 2, overflow: TextOverflow.clip,
                    ),
                    SizedBox(height: 5.0,),
                    Text(widget.time.toString(),
                      overflow: TextOverflow.clip,
                    ),
                    SizedBox(height: 5.0,),
                    Text(widget.place,
                      overflow: TextOverflow.clip,
                    ),
                  ],
                ),
              ),
              SizedBox(
                width: 50.0,
                child: Align(
                  alignment: Alignment.centerRight,
                  child: Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: IconButton(
                      onPressed: () {},
                      icon: Icon(Icons.favorite_border)),
                  )),
              ),
            ],
          ),
        ),
      ),
    );
  }
}  

最佳答案

Card 小部件有自己的剪辑行为,因此您只需将 clipBehavior 属性设置为 Clip.antiAlias卡片会被剪掉

https://stackoverflow.com/questions/52796767/

相关文章:

android-studio - Flutter 如何在 Android Studio 中制作发布版

flutter - 如何在 flutter 中向列添加滚动

flutter - 带有动画提示/标签的文本字段

flutter - 构造函数中的 Key 参数是什么

dart - 在 Dart 的 Cloud Firestore 中添加文档后如何获取文档 ID

flutter - CupertinoPageScaffold 的子小部件位于 CupertinoN

dart - Flutter 如何将 String 转换为 List

dart - Flutter:如何获取 http 请求的上传/下载进度

dart - Flutter 突然无法将 apk 安装到真机

dart - 将 ListTile 图标左对齐