build method
Widget
build({
- required Widget measuredChild,
- ScrollController? scrollController,
- ScrollPhysics? physics,
- bool outerScroll = true,
生成 EasyRefresh 实例。
Implementation
Widget build({
required Widget measuredChild,
ScrollController? scrollController,
ScrollPhysics? physics,
bool outerScroll = true,
}) {
return EasyRefresh.builder(
controller: controller,
header: header,
footer: footer,
onRefresh: onRefresh,
onLoad: onLoad,
notRefreshHeader: notRefreshHeader,
notLoadFooter: notLoadFooter,
simultaneously: simultaneously ?? false,
canRefreshAfterNoMore: canRefreshAfterNoMore ?? false,
canLoadAfterNoMore: canLoadAfterNoMore ?? false,
resetAfterRefresh: resetAfterRefresh ?? true,
refreshOnStart: refreshOnStart ?? false,
refreshOnStartHeader: refreshOnStartHeader,
callRefreshOverOffset: callRefreshOverOffset ?? 20,
callLoadOverOffset: callLoadOverOffset ?? 20,
spring: spring,
frictionFactor: frictionFactor,
scrollBehaviorBuilder: scrollBehaviorBuilder,
triggerAxis: triggerAxis,
scrollController: this.scrollController ?? scrollController,
childBuilder: (context, refreshPhysics) {
if (!outerScroll) {
// 在不使用外层 SingleChildScrollView 时,通过 ScrollConfiguration
// 透传 refreshPhysics,使得自带滚动的子组件能够完美对接下拉刷新
return ScrollConfiguration(
behavior: ScrollConfiguration.of(
context,
).copyWith(physics: refreshPhysics),
child: measuredChild,
);
}
// 优先使用 refreshPhysics 以确保下拉刷新功能正常工作
final ScrollPhysics effectivePhysics = refreshPhysics;
final ScrollController? effectiveController =
this.scrollController ?? scrollController;
return SingleChildScrollView(
controller: effectiveController,
physics: effectivePhysics,
primary: effectiveController == null,
child: measuredChild,
);
},
);
}