buildBaseViewStateEasyRefresh method
Widget
buildBaseViewStateEasyRefresh({
- ScrollController? scrollController,
- Widget? busyWidget,
- Widget? footWidget,
- ViewStateWidgetBuilder? emptyWidgetBuilder,
- ViewStateWidgetBuilder? errorWidgetBuilder,
- bool showErrorWidget = true,
- bool showEmptyWidget = true,
- bool showBusyWidget = true,
- Function? onLoad,
- Function? onRefresh,
- List<
Widget> ? widgetList, - Widget? widget,
inherited
底层建立下拉刷新
Implementation
Widget buildBaseViewStateEasyRefresh({
ScrollController? scrollController,
Widget? busyWidget,
Widget? footWidget,
ViewStateWidgetBuilder? emptyWidgetBuilder,
ViewStateWidgetBuilder? errorWidgetBuilder,
bool showErrorWidget = true,
bool showEmptyWidget = true,
bool showBusyWidget = true,
Function? onLoad,
Function? onRefresh,
List<Widget>? widgetList,
Widget? widget,
}){
if(ObjectUtil.isNotEmpty(widgetList)) {
if(isBusy || isError){
widgetList = [
SliverToBoxAdapter(
child: Container(),
)
];
}
}else if(ObjectUtil.isNotEmpty(widget)){
if(isBusy || isError){
widget = Container();
}
}
Widget? emptyErrorWidget = buildRefreshNoDataWidget(
viewState: this,
busyWidget: busyWidget,
emptyWidgetBuilder: emptyWidgetBuilder,
errorWidgetBuilder: errorWidgetBuilder,
showErrorWidget: showErrorWidget,
showEmptyWidget: showEmptyWidget,
showBusyWidget: showBusyWidget
);
bool useSliverWidget;
if(ObjectUtil.isNotEmpty(widgetList)){
useSliverWidget = true;
}else{
useSliverWidget = false;
}
Widget child = useSliverWidget? EasyRefresh.custom(
slivers: widgetList,
scrollController: scrollController,
taskIndependence: true,
controller: refreshController,
emptyWidget: emptyErrorWidget,
onLoad: isBusy? null : ObjectUtil.isEmpty(onLoad)? null : () async{
onLoad?.call();
},
onRefresh: isBusy? null : () async{
onRefresh?.call();
},
) : EasyRefresh(
scrollController: scrollController,
emptyWidget: emptyErrorWidget,
child: widget,
controller: refreshController,
onRefresh: isBusy? null : () async{
onRefresh?.call();
},
onLoad: isBusy? null : ObjectUtil.isEmpty(onLoad)? null : () async{
onLoad?.call();
},
);
return SizeCacheWidget(
child: child,
);
}