Skip to content

GridViewObserver 包裹MasonryGridView,使用animateTo,滚动不到对应的下标 widget #133

@wlingf

Description

@wlingf

Version

1.26.1

Platforms

dart

Device Model

pixel 6 pro

flutter info

Flutter (Channel stable, 3.24.5, on macOS 15.4.1 24E263 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.24.5 on channel stable at /Users/chenyaolong/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (8 months ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

How to reproduce?

Logs

Example code (optional)

GridObserverController observerController = GridObserverController(controller: scrollController);

GridViewObserver(
      child: MasonryGridView.builder(
          shrinkWrap: true,
          crossAxisSpacing: crossAxisSpacing,
          mainAxisSpacing: mainAxisSpacing,
          padding: padding,
          physics: ClampingScrollPhysics(),
          itemCount: count,
          controller:
          useScrollController ? logic.getOtherState().scrollController : null,
          gridDelegate: SliverSimpleGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: crossAxisCount),
          itemBuilder: itemBuilder),
      controller: observerController,
    )

observerController.animateTo(
      index: index,
      duration: const Duration(milliseconds: 500),
      curve: Curves.easeInOut,
    );

Contact

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions