baseRefreshState method
Widget
baseRefreshState(
- NotifierBuilder<
T?> widget, { - ScrollController? scrollController,
- bool validNullable = true,
- bool? shimmer,
- Color? baseColor,
- Color? highlightColor,
- Widget onPlaceholderWidget()?,
- String? placeholderEmptyImagePath,
- String? placeholderEmptyTitle,
- String? placeholderEmptyMessage,
- bool firstRefresh = false,
- VoidCallback? onRefresh,
- VoidCallback? onLoading,
- void onReloadTap()?,
Implementation
Widget baseRefreshState(
NotifierBuilder<T?> widget, {
ScrollController? scrollController,
bool validNullable = true,
bool? shimmer,
Color? baseColor,
Color? highlightColor,
Widget Function()? onPlaceholderWidget,
String? placeholderEmptyImagePath,
String? placeholderEmptyTitle,
String? placeholderEmptyMessage,
bool firstRefresh = false,
VoidCallback? onRefresh,
VoidCallback? onLoading,
void Function()? onReloadTap,
}) {
_placeholderEmptyTitle = placeholderEmptyTitle;
return SimpleBuilder(builder: (_) {
Widget? emptyWidget() {
if (status.isLoading && shimmer == true) {
return BaseShimmer(
visible: true,
child: widget(state),
baseColor: baseColor,
highlightColor: highlightColor,
);
}
return onPlaceholderWidget != null
? onPlaceholderWidget()
: BasePlaceholderView(
title: getPlaceholderTitle(placeholderEmptyTitle),
message: getPlaceholderMessage(placeholderEmptyMessage),
// 指定当前页面的占位图路径(网络默认placeholder_remote错误除外, 默认placeholder_empty)
image: placeholderEmptyImagePath,
onTap: onReloadTap ??
() {
change(state, status: RxStatus.loading());
onRequestPage(page);
},
);
}
return BaseRefresh(
controller: refreshController,
scrollController: scrollController,
emptyWidget:
(validNullable && state.isEmptyOrNull) ? emptyWidget() : null,
firstRefresh: firstRefresh,
onRefresh: implementationOnRefresh && !status.isLoading
? (onRefresh ?? () async => onRequestPage(kFirstPage))
: null,
onLoading: implementationOnLoad && state != null && !status.isLoading
? (onLoading ?? () async => onRequestPage(page + 1))
: null,
child: (state == null && !status.isSuccess ||
(validNullable && state.isEmptyOrNull))
? emptyWidget() ?? SizedBox()
: widget(state),
);
});
}