Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在Flatter中的ListView中添加一个可拒绝的小部件?_Flutter_Dart - Fatal编程技术网

Flutter 如何在Flatter中的ListView中添加一个可拒绝的小部件?

Flutter 如何在Flatter中的ListView中添加一个可拒绝的小部件?,flutter,dart,Flutter,Dart,我有一个列表视图,我想添加一个可忽略的小部件。我希望列表视图中的项目在单击时消失。我还想在列表的所有元素结束后删除整个列表的标题。 是否有可能使ListTile与Dismissible小部件或任何其他此类小部件一起消失 这是我的列表视图的代码: SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.only(left: 12.0), child: Container(

我有一个列表视图,我想添加一个可忽略的小部件。我希望列表视图中的项目在单击时消失。我还想在列表的所有元素结束后删除整个列表的标题。 是否有可能使ListTile与Dismissible小部件或任何其他此类小部件一起消失

这是我的列表视图的代码:

    SliverToBoxAdapter(
        child: Padding(
      padding: const EdgeInsets.only(left: 12.0),
      child: Container(
        child: Text(
          'New User Tasks',
          style: TextStyle(
            fontSize: 26.0,
            fontWeight: FontWeight.w600,
            fontFamily: "Netflix",
            color: Colors.orange,
          ),
        ),
      ),
    )),

    SliverFixedExtentList(
      itemExtent: 80.0,
      delegate: SliverChildBuilderDelegate(
        (BuildContext context, int index) {
          Divider(
            color: Colors.orange,
            height: 7.0,
          );
          ChatModel _model = ChatModel.dummyData[index];
          return Container(
            alignment: Alignment.center,
            color: Colors.transparent,
            child: GestureDetector(
              onTap: () {
                if (index == 0) {
                  print('Hello');
                }
                if (index == 1) {
                  print('Helyyylo');

                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (context) => SettingsView(),
                    ),
                  );
                }
                if (index == 2) {
                  print('Heooooo');
                }
              },
              child: Column(
                children: <Widget>[
                  Divider(
                    height: 4.0,
                  ),
                  ListTile(
                    leading: ClipRRect(
                      borderRadius: BorderRadius.circular(12.0),
                      child: Container(
                        // height:80,
                        // width:30,

                        child: Image.asset(_model.imagePath),
                      ),
                    ),
                    title: Row(
                      children: <Widget>[
                        Text(
                          _model.name,
                          style: TextStyle(
                            fontSize: 17.0,
                            fontWeight: FontWeight.w600,
                            fontFamily: "Netflix",
                            color: Colors.orange,
                          ),
                        ),
                        SizedBox(
                          width: 16.0,
                        ),
                      ],
                    ),
                    subtitle: Text(
                      _model.message,
                      style: TextStyle(
                        fontSize: 15.0,
                        fontFamily: "Netflix",
                      ),
                    ),
                  ),
                ],
              ),
            ),
          );
        },
        childCount: 3,
      ),
    ),
SliveToboxAdapter(
孩子:填充(
填充:仅限常量边集(左:12.0),
子:容器(
子:文本(
“新用户任务”,
样式:TextStyle(
字体大小:26.0,
fontWeight:fontWeight.w600,
fontFamily:“Netflix”,
颜色:颜色。橙色,
),
),
),
)),
SliverFixedExtentList(
项目范围:80.0,
代表:SliverChildBuilderDelegate(
(BuildContext上下文,int索引){
分隔器(
颜色:颜色。橙色,
身高:7.0,
);
ChatModel _model=ChatModel.dummyData[index];
返回容器(
对齐:对齐.center,
颜色:颜色。透明,
儿童:手势检测器(
onTap:(){
如果(索引==0){
打印(“你好”);
}
如果(索引==1){
打印('Helyyyylo');
导航器。推(
上下文
材料路线(
生成器:(上下文)=>SettingsView(),
),
);
}
如果(索引==2){
印刷品('heoooo');
}
},
子:列(
儿童:[
分隔器(
身高:4.0,
),
列表砖(
前导:ClipRRect(
边界半径:边界半径。圆形(12.0),
子:容器(
//身高:80,
//宽度:30,
子项:Image.asset(_model.imagePath),
),
),
标题:世界其他地区(
儿童:[
正文(
_model.name,
样式:TextStyle(
字体大小:17.0,
fontWeight:fontWeight.w600,
fontFamily:“Netflix”,
颜色:颜色。橙色,
),
),
大小盒子(
宽度:16.0,
),
],
),
字幕:文本(
_model.message,
样式:TextStyle(
字体大小:15.0,
fontFamily:“Netflix”,
),
),
),
],
),
),
);
},
儿童人数:3,
),
),
其中:

class ChatModel {
  final String imagePath;
  final String name;
  final String datetime;
  final String message;

  ChatModel({this.imagePath, this.name, this.datetime, this.message});

  static final List<ChatModel> dummyData = [
    ChatModel(
      imagePath: 'assets/app/star1.jpg',
      name: "Rate Us",
      datetime: "20:18",
      message: "I love the app",
    ),
    ChatModel(
      imagePath: 'assets/app/test.jpg',
      name: "Invite Code",
      datetime: "19:22",
      message: "I love that idea, it's great!",
    ),
    ChatModel(
      imagePath: 'assets/app/share1.png',
      name: "First Poll Reward",
      datetime: "14:34",
      message: "I wasn't aware of that. Let me check",
    ),
}
类模型{
最终字符串图像路径;
最后的字符串名;
最终字符串日期时间;
最终字符串消息;
ChatModel({this.imagePath,this.name,this.datetime,this.message});
静态最终列表dummyData=[
聊天室模型(
imagePath:'assets/app/star1.jpg',
名称:“给我们打分”,
日期时间:“20:18”,
信息:“我喜欢这个应用程序”,
),
聊天室模型(
imagePath:'assets/app/test.jpg',
名称:“邀请代码”,
日期时间:“19:22”,
信息:“我喜欢这个主意,太棒了!”,
),
聊天室模型(
imagePath:'assets/app/share1.png',
名称:“首次投票奖励”,
日期时间:“14:34”,
留言:“我不知道,让我检查一下”,
),
}

点击移除项目

onTap: () {
 setState((){
   ChatModel.dummyData.removeAt(index);
 });
}