Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/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
Android ListView内部的ListView颤振_Android_Listview_Flutter_Dart_Stream - Fatal编程技术网

Android ListView内部的ListView颤振

Android ListView内部的ListView颤振,android,listview,flutter,dart,stream,Android,Listview,Flutter,Dart,Stream,正在尝试复制google MyTasks应用程序,但无法为任务列表提供解决方案 基本上是尝试这样的布局: 如果我理解正确,这是两个列表视图:一个是挂起的任务,另一个是已完成的任务。已完成的任务位于ExpansionFile内。挂起的任务按日期分隔 目前,我有一个listView生成器: 显示项目的主列表: Widget build(BuildContext context) { final dao = Provider.of<TodoDao>(context);

正在尝试复制google MyTasks应用程序,但无法为任务列表提供解决方案

基本上是尝试这样的布局:

如果我理解正确,这是两个列表视图:一个是挂起的任务,另一个是已完成的任务。已完成的任务位于ExpansionFile内。挂起的任务按日期分隔

目前,我有一个listView生成器:

显示项目的主列表:



  Widget build(BuildContext context) {
    final dao = Provider.of<TodoDao>(context);

    return ListView(
      shrinkWrap: true,
      children: <Widget>[
        _buildTaskList(context),
        ExpansionTile(
          title: Text('Completed tasks'),
          children: <Widget>[_buildCompletedTodoList(context)],
        )
      ],
    );
  }


小部件构建(构建上下文){
final dao=Provider.of(上下文);
返回列表视图(
收缩膜:对,
儿童:[
_构建任务列表(上下文),
扩展文件(
标题:文本(“已完成的任务”),
子项:[[u buildCompletedTodoList(上下文)],
)
],
);
}
建筑待处理清单



  StreamBuilder<List<Task>> _buildTaskList(BuildContext context) {
    final dao = Provider.of<TodoDao>(context);

    return StreamBuilder(
      stream: dao.watchAllTasks(),
      builder: (context, AsyncSnapshot<List<Task>> snapshot) {
        final tasks = snapshot.data ?? List();

        return ListView.builder(
          itemCount: tasks.length,
          itemBuilder: (_, index) {
            final itemTask = tasks[index];

            return _buildListItem(itemTask, dao);
          },
        );
      },
    );
  }


  Widget _buildListItem(Task itemTask, TodoDao dao) {
    return Dismissible(
      direction: DismissDirection.horizontal,
      key: Key(itemTask.id.toString()),
      onDismissed: (direction) {
        dao.deleteTask(itemTask);
      },
      background: Container(
        color: Colors.blue,
        child: Align(
          alignment: Alignment.centerLeft,
          child: Padding(
            padding: const EdgeInsets.only(left: 16.0),
            child: Icon(
              Icons.check,
              color: Colors.white,
              size: 32.0,
            ),
          ),
        ),
      ),
      secondaryBackground: Container(
        color: Colors.red,
        child: Align(
          alignment: Alignment.centerRight,
          child: Icon(
            Icons.delete,
            color: Colors.white,
            size: 32.0,
          ),
        ),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          _buildCheckboxListTile(itemTask, dao),
          Divider(
            height: 8.0,
            color: Color.fromRGBO(150, 150, 150, 0.8),
          ),
        ],
      ),
    );

  }

StreamBuilder\u buildTaskList(BuildContext上下文){
final dao=Provider.of(上下文);
返回流生成器(
stream:dao.watchAllTasks(),
生成器:(上下文,异步快照){
最终任务=snapshot.data??List();
返回ListView.builder(
itemCount:tasks.length,
itemBuilder:(\ux,索引){
最终项目任务=任务[索引];
返回_buildListItem(itemTask,dao);
},
);
},
);
}
小部件_buildListItem(任务项任务,TodoDao dao){
可驳回的回报(
方向:DismissDirection.horizontal,
key:key(itemTask.id.toString()),
onDismissed:(方向){
deleteTask(itemTask);
},
背景:集装箱(
颜色:颜色,蓝色,
子对象:对齐(
对齐:alignment.centerLeft,
孩子:填充(
填充:仅限常量边集(左:16.0),
子:图标(
图标。检查,
颜色:颜色,白色,
尺寸:32.0,
),
),
),
),
第二背景:容器(
颜色:颜色,红色,
子对象:对齐(
对齐:alignment.centerRight,
子:图标(
图标。删除,
颜色:颜色,白色,
尺寸:32.0,
),
),
),
子:列(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
_buildCheckboxListTile(itemTask,dao),
分隔器(
身高:8.0,
颜色:颜色。来自RGBO(150、150、150、0.8),
),
],
),
);
}
对于完整的列表,几乎相同的代码,只是不同的流和ListItemUI

通过这段代码,我在一个列表中同时获得了挂起的listView和ExpansionFile,但它们与

另外,如果我在挂起列表中添加了很多项,我将无法向下滚动,因为我使用srinkWrap,否则会出现大量错误

所以,是的,我不知道这个公式是否正确,也不知道是否有人理解我在说什么,但我只是想知道如何创建类似于MyTasks应用程序的任务列表。

您需要的是一个带有扩展文件小部件的单列表视图。 基本上,在手机上有多个滚动条是个坏主意。(查看Android/iOS指南)