quire-io / scroll-to-index

scroll to index with fixed/variable row height inside Flutter scrollable widget
MIT License
518 stars 105 forks source link

Blocked scroll #54

Closed kavodsky closed 3 years ago

kavodsky commented 3 years ago

After itemScrollController.scrollTo is called list scroll is blocked, only items which fit screen are visible.

  return FutureBuilder(
        // future: CloudFirestoreDatabaseService.getDictionaryWords(dictionariId),
        future: FloorDatabaseService.getDictionaryWordVies(dictionaryId),
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.none &&
                  !snapshot.hasData ||
              snapshot.connectionState == ConnectionState.waiting) {
            return Center(child: CircularProgressIndicator());
          }
          words = snapshot.data as List<DictionaryWordView>;
          final ItemScrollController itemScrollController =
              ItemScrollController();
          final ItemPositionsListener itemPositionsListener =
              ItemPositionsListener.create();
          itemPositionsListener.itemPositions.addListener(() => {
                itemScrollController.scrollTo(
                    index: 15,
                    duration: Duration(milliseconds: 50),
                    curve: Curves.easeInOutCubic)
              });
          return words.length == 0
              ? Center(
                  child: Text(
                  'No words found. Please synchronize with remote dictionary.',
                  textAlign: TextAlign.center,
                ))
              : ScrollablePositionedList.builder(
                  itemCount: words.length,
                  itemBuilder: (context, index) {
                    DictionaryWordView wordView = words[index];
                    return WordCard(
                      wordView: wordView,
                      callback: callback,
                    );
                  },
                  itemScrollController: itemScrollController,
                  itemPositionsListener: itemPositionsListener,
                  scrollDirection: Axis.vertical,
                );
        });
jerrywell commented 3 years ago

guess you are using another package. please fire the issue at https://github.com/google/flutter.widgets/tree/master/packages/scrollable_positioned_list