首页 > 解决方案 > 如何从 Cloud Firestore 获取嵌套数组的数据以进行颤动?

问题描述

我需要从主题数组中获取数据。主题数组包含多个映射,每个映射包含另一个数组。我需要从嵌套数组中获取数据并将其显示到 ListView。在这里我附上我的数据库和我的代码。

在此处输入图像描述

      Padding(
          padding: const EdgeInsets.all(8.0),
              child: GetBuilder<DataController>(
                  init: DataController(),
                  builder: (value) {
                    return FutureBuilder(
                        future: value.getData('englishcategories'),
                        builder: (context, snapshot) {
                          if (snapshot.connectionState ==
                              ConnectionState.waiting) {
                            return Center(
                              child: CircularProgressIndicator(
                                backgroundColor: Colors.black,
                              ),
                            );
                          } else {
                            return SingleChildScrollView(
                              child: ListView.builder(
                                shrinkWrap: true,
                                scrollDirection: Axis.vertical,
                                itemCount: snapshot.data.length,
                                // itemCount: snapshot.data[],
                                itemBuilder:
                                    (BuildContext context, int index) {
                                  return Container(
                                    height:
                                        MediaQuery.of(context).size.height,
                                    child: SingleChildScrollView(
                                      child: Padding(
                                        padding: const EdgeInsets.only(
                                            left: 15, right: 15),
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            Text(
                                              '',
                                              // Get.arguments['subject']
                                              //     [index]['duration'][index],
                                              style: TextStyle(
                                                  height: 1.4,
                                                  fontSize: 28,
                                                  color: Colors.black
                                                      .withOpacity(0.9),
                                                  fontWeight:
                                                      FontWeight.w700,
                                                  fontFamily: 'Raleway'),
                                            ),

标签: arraysflutterdartgoogle-cloud-firestorenested

解决方案


推荐阅读