monster555 / flutter_elastic_list_view

A Flutter package providing elastic scrolling effect in ListView.builder with enhanced functionality and customization.
https://pub.dev/packages/flutter_elastic_list_view
MIT License
63 stars 10 forks source link

When adding a refresh indicator with scroll controller attached to the listview, scroll controller gets disposed and I can't find a way to fix it. #1

Closed Ashwin1002 closed 1 week ago

Ashwin1002 commented 9 months ago

The error is : ════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown building NotificationListener: A ScrollController was used after being disposed. Once you have called dispose() on a ScrollController, it can no longer be used. The relevant error-causing widget was: RefreshIndicator RefreshIndicator:file:///Users/ashwinshrestha/development/medhavhi_app/lib/src/class/presentation/paginated_list/view/paginated_list_view.dart:87:53

The code is:

RefreshIndicator.adaptive( onRefresh: () async => _paginationBloc.add(const FetchItems(refresh: true)), child: ElasticListView( // controller: _scrollController, itemCount: state.hasReachedMax ? state.data.length : state.data.length + 1, itemBuilder: (context, index) { return index >= state.data.length ? widget.paginationLoadingWidget ?? SizedBox( height: 80.v, width: context.deviceWidth, child: const Center( child: CupertinoActivityIndicator(), ), ) : widget.itemBuilder(context, index, state.data[index]); }, ), )

monster555 commented 8 months ago

Hey!

Thanks for opening this issue. ElasticListView is now a package. I tried to reproduce your error but was unable to replicate the issue. Could you please verify with the new package and let me know if the issue still exists? If it does, sharing a code snippet would be very helpful for further debugging.