Skip to content

Unable to trigger refresh/load when child widget is GroupedListView #648

Open
@TreyThomas93

Description

@TreyThomas93

The following code will let me scroll the listview, but will not trigger the SmartRefresher to refresh or load new data. I'm using the GroupedListView dependency as its child, and I noticed that if I replace that with a normal ListView.builder, that it will work. So not sure what the issue is. Any assistance would be helpful. Thanks!

return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text('Title'),
          Expanded(
            child: messages.when(
              data: (data) {
                // if empty
                if (data.isEmpty) {
                  return const Center(
                    child: Text('No messages yet'),
                  );
                }

                // sort messages by timestamp
                data.sort((a, b) => a.timestamp.compareTo(b.timestamp));
      
                return SmartRefresher(
                  controller: _refreshController,
                  enablePullDown: true,
                  onRefresh: () async {
                    // code....
                  },
                  onLoading: () async {
                   // code....
                  },
                  child: Scrollbar(
                    controller: _scrollController,
                    child: GroupedListView<Message, String>(
                      physics: const AlwaysScrollableScrollPhysics(),
                      controller: _scrollController,
                      elements: data,
                      groupBy: (element) =>
                          element.timestamp.toLocal().monthDayYear,
                      groupSeparatorBuilder: (String groupByValue) => Text('Group Name'),
                      itemBuilder: (context, element) {
                        return ListTile(title: Text('Message'));
                      },
                      order: GroupedListOrder.DESC,
                      sort: false,
                    ),
                  ),
                );
              },
              error: (error, stack) {
                log('Error: $error, Stack: $stack');
                return Center(
                  child: Text('Error: $error'),
                );
              },
              loading: () => const Center(child: CircularProgressIndicator()),
            ),
          ),
         // other code...
        ],
      ),
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions