简体   繁体   English

flutter - 同时滚动两个列表视图

[英]flutter - To scroll through two list views at the same time

I want to implement the function of two lists scrolling at the same time.我想实现两个列表同时滚动的功能。 I put two non-scrollable lists in the list, but an error occurs.我在列表中放了两个不可滚动的列表,但是出现错误。

I got offset from one list, and the other came up with the idea of moving to that offset, but I couldn't find a way.我从一个列表中得到了抵消,而另一个提出了转移到那个抵消的想法,但我找不到办法。

I'd like you to tell me what to do or suggest a new way.我希望你告诉我该怎么做或建议一种新的方法。 This problem is important to me.这个问题对我很重要。 Please tell me how.请告诉我怎么做。

在此处输入图片说明

                  Row(
                    children: [
                      Expanded(
                        child: SizedBox(
                          height: 200,
                          child: ListView(
                            // scrollDirection: Axis.horizontal,
                            children: [
                              Container(
                                height: 36,
                                child: ListView.builder(
                                  physics: NeverScrollableScrollPhysics(),
                                  itemCount:
                                      _selectedTimeStartBtn ? 24 : 49,
                                  scrollDirection: Axis.horizontal,
                                  itemBuilder: (context, index) {
                                    return Container(
                                      alignment: Alignment.center,
                                      padding: const EdgeInsets.symmetric(
                                          horizontal: 17, vertical: 7),
                                      decoration: new BoxDecoration(
                                        color: Color(0xfffff2f1),
                                        border: Border.all(
                                          color: Color(0xffffdddb),
                                        ),
                                        borderRadius:
                                            BorderRadius.circular(5),
                                      ),
                                      child: Text(
                                        (index ~/ 24 == 2)
                                            ? '24:00'
                                            : (index % 24 < 10)
                                                ? '0${index % 24}:00'
                                                : '${index % 24}:00',
                                        textAlign: TextAlign.center,
                                        style: TextStyle(
                                          fontFamily: 'NotoSansKR',
                                          color: Color(0xfff03127),
                                          fontSize: 16,
                                          fontWeight: FontWeight.w400,
                                          fontStyle: FontStyle.normal,
                                        ),
                                      ),
                                    );
                                  },
                                ),
                              ),
                              Container(
                                height: 36,
                                child: ListView.builder(
                                  shrinkWrap: true,
                                  physics: NeverScrollableScrollPhysics(),
                                  itemCount:
                                      _selectedTimeStartBtn ? 24 : 49,
                                  scrollDirection: Axis.horizontal,
                                  itemBuilder: (context, index) {
                                    return Container(
                                      margin: index == 0
                                          ? EdgeInsets.only(left: 50)
                                          : null,
                                      alignment: Alignment.center,
                                      padding: const EdgeInsets.symmetric(
                                          horizontal: 17, vertical: 7),
                                      decoration: new BoxDecoration(
                                        color: Colors.grey,
                                        border: Border.all(
                                          color: Colors.grey,
                                        ),
                                        borderRadius:
                                            BorderRadius.circular(5),
                                      ),
                                      child: Text('DATA'),
                                    );
                                  },
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),

Try this:尝试这个:

  1. Wrap your Row in a SingleChildScrollView.将您的 Row 包裹在 SingleChildScrollView 中。
  2. Use scrollDirection: Axis.horizontal in the SingleChildScrollView.在 SingleChildScrollView 中使用 scrollDirection: Axis.horizo​​ntal。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM