Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义Footer,NoMore时,盖在列表上了 #868

Open
onism0106 opened this issue Oct 16, 2024 · 2 comments
Open

自定义Footer,NoMore时,盖在列表上了 #868

onism0106 opened this issue Oct 16, 2024 · 2 comments

Comments

@onism0106
Copy link

onism0106 commented Oct 16, 2024

自定义的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不动了,盖在了列表上
是哪里出问题了嘛?

@wangbf11
Copy link

我也遇见同样的问题 tabview和这个下拉刷新组件 一起用的时候必定出现

@JoinLi
Copy link

JoinLi commented Jan 11, 2025

翻阅源码,发现作者的自定义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();
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants