mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
Refactor notification handling in SidebarCommunitiesList for improved readability and maintainability.
This commit is contained in:
@ -16,6 +16,16 @@ class SidebarCommunitiesList extends StatelessWidget {
|
||||
final ScrollController scrollController;
|
||||
final void Function() onScrollToEnd;
|
||||
|
||||
bool _onNotification(ScrollEndNotification notification) {
|
||||
final hasReachedEnd = notification.metrics.extentAfter == 0;
|
||||
if (hasReachedEnd) {
|
||||
onScrollToEnd.call();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@ -26,17 +36,11 @@ class SidebarCommunitiesList extends StatelessWidget {
|
||||
scrollbarOrientation: ScrollbarOrientation.left,
|
||||
thumbVisibility: true,
|
||||
controller: scrollController,
|
||||
child: NotificationListener(
|
||||
onNotification: (notification) {
|
||||
if (notification is ScrollEndNotification &&
|
||||
notification.metrics.extentAfter == 0) {
|
||||
onScrollToEnd.call();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: NotificationListener<ScrollEndNotification>(
|
||||
onNotification: _onNotification,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsetsDirectional.only(start: 16),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsetsDirectional.only(start: 16),
|
||||
itemCount: communities.length,
|
||||
controller: scrollController,
|
||||
itemBuilder: itemBuilder,
|
||||
|
Reference in New Issue
Block a user