自定义Footer,NoMore时,盖在列表上了
自定义的Footer代码如下:
footer: BuilderFooter(
triggerOffset: 70,
clamping: false,
position: IndicatorPosition.above,
processedDuration: Duration.zero,
builder: (context, state) {
if (state.mode == IndicatorMode.processing) {
return Padding(
padding: const EdgeInsets.only(
top: 12.0,
bottom: 12.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ExtendedImage(
width: 12.0,
height: 12.0,
clearMemoryCacheWhenDispose: true,
image: AssetImage(
GetExt.isDarkMode
? 'res/images/dark/icon_load_more.png'
: 'res/images/icon_load_more.png',
package: 'flutter_template_sdk',
),
),
Container(
margin: const EdgeInsets.only(left: 8.0),
child: Text(
'正在加载',
style: TextStyle(
fontSize: 13.0,
color: Theme.of(context)
.extension<FlutterTemplateSdkColors>()!
.clTextLevel3,
),
),
),
],
),
);
}
if (state.result == IndicatorResult.noMore) {
return Text('没有更多数据了');
}
return SizedBox.shrink();
},
),
当列表没有更多内容时,显示了noMore的Footer,但是列表再向上滑时,Footer不动了,盖在了列表上 是哪里出问题了嘛?
我也遇见同样的问题 tabview和这个下拉刷新组件 一起用的时候必定出现
翻阅源码,发现作者的自定义footer高度需要动态计算。 简单实现如下 class CustomFooter extends Footer { CustomFooter({ super.triggerOffset=35, super.clamping=false, super.position= IndicatorPosition.behind});
@override Widget build(BuildContext context, IndicatorState state) { double offset = state.offset; if (state.indicator.infiniteOffset != null && state.indicator.position == IndicatorPosition.locator && (state.mode != IndicatorMode.inactive || state.result == IndicatorResult.noMore)) { offset = state.actualTriggerOffset; } if (IndicatorMode.processing == state.mode) { return Container(height: offset,child: Text("加载中"),); } if (IndicatorResult.noMore == state.result) { return Container(height: offset,child: Text("加载完成"),); } return Container(); } }