ListUicController<T> constructor
ListUicController<T> ({})
Implementation
ListUicController({
List<T>? items,
required this.onGetItems,
this.initialLoading = true,
this.allowPagination = true,
}) {
_items = ValueNotifier(items ?? <T>[]);
_page = 1;
if (_items.value.isEmpty) {
if (initialLoading) {
_state = ValueNotifier(_ListUicState.emptyProgress);
refresh();
} else {
_state = ValueNotifier(_ListUicState.emptyData);
}
} else {
_state = ValueNotifier(_ListUicState.data);
}
if (allowPagination) {
_scrollController.addListener(() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
if (_readyForNextPage) {
_readyForNextPage = false;
nextPage();
}
} else if (_scrollController.position.pixels <=
_scrollController.position.maxScrollExtent - 10.0) {
_readyForNextPage = true;
}
});
}
}