在Flatter中使用Dismissible小部件时,ListTile覆盖父容器

在Flatter中使用Dismissible小部件时,ListTile覆盖父容器,list,flutter,listview,tile,dismissible,List,Flutter,Listview,Tile,Dismissible,我将一个ListTile包装在一个容器中,当我用Dismissible和swipe将其包装时,它会重叠并越过主容器。如图所示 这是我的主容器的代码: Container( height: 500, width: 500, decoration: BoxDecoration( borderRadius: BorderRadius.c

我将一个ListTile包装在一个容器中,当我用Dismissible和swipe将其包装时,它会重叠并越过主容器。如图所示

这是我的主容器的代码:

Container(
                    height: 500,
                    width: 500,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(10),
                        color: Colors.white),
                    child: FutureBuilder<List<EntryRecord>>(
                      future: _getAllRecords(user),
                      builder:
                          (BuildContext context, AsyncSnapshot snapshot) {
                        if (snapshot.hasData) {
                          return ListView.builder(
                   
                              itemCount: snapshot.data.length,
                              itemBuilder:
                                  (BuildContext context, int index) {
                                return Dismissible(
                                  direction: DismissDirection.endToStart,
                                  key: ObjectKey(snapshot.data[index]),
                                  onDismissed: (direction) {
                                    ScaffoldMessenger.of(context)
                                        .showSnackBar(
                                      SnackBar(
                                        content: Text(
                                            "${snapshot.data[index].number} has been deleted"),
                                      ),
                                    );
                                  },
                            
                                  child: EntryCard(
                                    record: snapshot.data[index],
                                    index: index,
                                  ),
                                );
                              });
                        } else {
                          return Center(
                            child: CircularProgressIndicator(),
                          );
                        }
                      },
                    ),
                  )
容器(
身高:500,
宽度:500,
装饰:盒子装饰(
边界半径:边界半径。圆形(10),
颜色:颜色。白色),
孩子:未来建设者(
未来:_getAllRecords(用户),
建设者:
(BuildContext上下文,异步快照){
if(snapshot.hasData){
返回ListView.builder(
itemCount:snapshot.data.length,
项目生成器:
(BuildContext上下文,int索引){
可驳回的回报(
方向:DismissDirection.endToStart,
key:ObjectKey(snapshot.data[index]),
onDismissed:(方向){
脚手架信使(上下文)
.showSnackBar(
小吃条(
内容:文本(
“${snapshot.data[index].number}已被删除”),
),
);
},
孩子:入场卡(
记录:snapshot.data[索引],
索引:索引,,
),
);
});
}否则{
返回中心(
子对象:CircularProgressIndicator(),
);
}
},
),
)
这是EntryCard小部件(使用ListView.builder构建的小部件)的代码

类入口卡扩展了无状态小部件{
入口记录;
整数指数;
入口卡({Key-Key,this.record,this.index}):超级(Key:Key);
列表颜色=[kLightOrange、kLightPurple、kLightBlue、kLightPink];
@凌驾
小部件构建(构建上下文){
返回容器(
保证金:所有(10),
装饰:盒子装饰(
梯度:线性梯度(
颜色:[colors.white,TinyColor(颜色[索引])。变深(8)。颜色],
开始:Alignment.centerLeft,
结束:对齐。中间右侧),
边界半径:边界半径。圆形(20),
),
孩子:ListTile(
onTap:(){},
标题:正文(
记录。标题,
样式:TextStyle(
颜色:TinyColor(颜色[索引])。变深(30)。颜色,
fontWeight:fontWeight.w500),
),
字幕:文本(record.url,
样式:TextStyle(颜色:Colors.grey,fontwweight:fontwweight.w500)),
领先:集装箱(
装饰:盒子装饰(
边界半径:边界半径。圆形(15),
颜色:TinyColor(颜色[索引])。变深(30)。颜色),
对齐:对齐.center,
宽度:80,
身高:200,
孩子:填充(
填充:常数边集全部(8.0),
子:文本(
record.number.toString(),
textAlign:textAlign.center,
溢出:TextOverflow.省略号,
样式:TextStyle(
颜色:颜色,白色,
尺寸:20,
fontWeight:fontWeight.w900),
),
),
),
尾随:图标(
Icons.share_概述,
颜色:颜色,白色,
),
//tileColor:颜色(0xFFF2784B),
),
);
}
}
我甚至尝试在一个可忽略的小部件中扭曲ListTile小部件,它给了我类似的结果

class EntryCard extends StatelessWidget {


EntryRecord record;
  int index;
  EntryCard({Key key, this.record, this.index}) : super(key: key);
  List<Color> colors = [kLightOrange, kLightPurple, kLightBlue, kLightPink];
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(10),
      decoration: BoxDecoration(
        gradient: LinearGradient(
            colors: [Colors.white, TinyColor(colors[index]).darken(8).color],
            begin: Alignment.centerLeft,
            end: Alignment.centerRight),
        borderRadius: BorderRadius.circular(20),
      ),
      child: ListTile(
        onTap: () {},
        title: Text(
          record.title,
          style: TextStyle(
              color: TinyColor(colors[index]).darken(30).color,
              fontWeight: FontWeight.w500),
        ),
        subtitle: Text(record.url,
            style: TextStyle(color: Colors.grey, fontWeight: FontWeight.w500)),
        leading: Container(
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(15),
              color: TinyColor(colors[index]).darken(30).color),
          alignment: Alignment.center,
          width: 80,
          height: 200,
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Text(
              record.number.toString(),
              textAlign: TextAlign.center,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: Colors.white,
                  fontSize: 20,
                  fontWeight: FontWeight.w900),
            ),
          ),
        ),
        trailing: Icon(
          Icons.share_outlined,
          color: Colors.white,
        ),
        // tileColor: Color(0xFFF2784B),
      ),
    );
  }
}