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

[How to use] 这个好像对WaterfallFlow不起作用 #107

Open
chenxuyuan2016 opened this issue Jan 8, 2025 · 1 comment
Open

[How to use] 这个好像对WaterfallFlow不起作用 #107

chenxuyuan2016 opened this issue Jan 8, 2025 · 1 comment
Assignees

Comments

@chenxuyuan2016
Copy link

Platforms

Android, iOS

Description

我看例子也没有对WaterfallFlow的使用,调用了jumpTo方法,但是界面上面一点响应都没有

My code

ScrollController scrollController = ScrollController();
SliverObserverController gridObserverController = SliverObserverController(controller: scrollController);

Widget createList() {
return SliverViewObserver(
controller: gridObserverController,
child: WaterfallFlow.builder(
controller: scrollController,
itemCount: state.length,
padding: EdgeInsets.symmetric(horizontal: 10.w),
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 2.w,
crossAxisSpacing: 2.w,
),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
behavior: HitTestBehavior.deferToChild,
onTap: () => _cardClick(context, index),
child: Hero(
tag: "$squareId:card:$index",
child: SquareCard(state.squareId, state.getItem(index), index,
_devicesClick, _heartLikeClick)),
);
},
),
);
}

 `gridObserverController.jumpTo(index: state.currentIndex, renderSliverType: ObserverRenderSliverType.grid,);`

Try do it

No response

@LinXunFeng
Copy link
Member

针对第三方滚动视图,需要告诉 scrollview_observer 如何处理观察

extendedHandleObserve: (context) {
// An extension of the original observation logic.
final _obj = ObserverUtils.findRenderObject(context);
if (_obj is RenderSliverWaterfallFlow) {
return ObserverCore.handleGridObserve(
context: context,
fetchLeadingOffset: () => observeOffset,
);
}
return null;
},
// customHandleObserve: (context) {
// // Here you can customize the observation logic.
// final _obj = ObserverUtils.findRenderObject(context);
// if (_obj is RenderSliverList) {
// ObserverCore.handleListObserve(context: context);
// }
// if (_obj is RenderSliverGrid || _obj is RenderSliverWaterfallFlow) {
// return ObserverCore.handleGridObserve(context: context);
// }
// return null;
// },

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

2 participants