如何在每组颤振天数的垂直 listView 中有多个水平 listView?

时间:2021-06-20 20:24:37

标签: flutter google-cloud-firestore

我成功地在 firestore 上保存和读取数据。目前,我显示了我所有 FireStore 集合的水平列表视图。

但首先显示所有日期,其次只显示一行

我搜索分离这一行,按天数按多个组排序

这是我当前的显示

Horizontal Listview => day1:data - day1:data - day2:data - day2:data ...

这是我搜索的内容

    Horizontal Listview number1 => day1:data day1:data
    Horizontal Listview number2 => day2:data day2:data
    ...

     StreamBuilder<List<Todo2>>(
                stream: FirebaseFirestore.instance
                    .collection('$current_id')
                    .orderBy(TodoField.createdTime, descending: true)
                    .snapshots()
                    .transform(Utils.transformer(Todo2.fromJson)),
                builder: (context, snapshot) {
                  switch (snapshot.connectionState) {
                    case ConnectionState.waiting:
                      return Center(child: CircularProgressIndicator());
                    default:
                      if (snapshot.hasError) {
                        return buildText('Something Went Wrong Try later');
                      } else {
                        final todos2 = snapshot.data;
                        final provider = Provider.of<TodosProvider>(context);
                        provider.setTodos2(todos2);
    
                        return    SizedBox(
                          height: MediaQuery.of(context).size.height / 2,
                          child:
                          TodoListWidget2(),
                        );
                      }
                  }
                },
              ),
      class TodoListWidget2 extends StatelessWidget {
         @override
         Widget build(BuildContext context) {
         final provider = Provider.of<TodosProvider>(context);
         final todos2 = provider.todos2;

        return todos2.isEmpty
           ? Center(
             child: Text(
              'Pas de suite',
           style: TextStyle(fontSize: 20),
         ),
        )
        : ListView.separated(
      padding: EdgeInsets.all(16),

      physics: BouncingScrollPhysics(),
      scrollDirection:  Axis.horizontal,
      separatorBuilder: (context, index) => Container(width: 8,height:8),
      itemCount: todos2.length,
      itemBuilder: (context, index) {
        final todo2 = todos2[index];

        return TodoWidget2(todo2: todo2);
      },
    );
  }
}

1 个答案:

答案 0 :(得分:1)

你在listView里面的水平视图看起来像 enter image description here

.idea