簡體   English   中英

flutter - 同時滾動兩個列表視圖

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

我想實現兩個列表同時滾動的功能。 我在列表中放了兩個不可滾動的列表,但是出現錯誤。

我從一個列表中得到了抵消,而另一個提出了轉移到那個抵消的想法,但我找不到辦法。

我希望你告訴我該怎么做或建議一種新的方法。 這個問題對我很重要。 請告訴我怎么做。

在此處輸入圖片說明

                  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'),
                                    );
                                  },
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),

嘗試這個:

  1. 將您的 Row 包裹在 SingleChildScrollView 中。
  2. 在 SingleChildScrollView 中使用 scrollDirection: Axis.horizo​​ntal。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM