Skip to content

feat: Implement ScrollCallbacks on new event system#3892

Merged
luanpotter merged 4 commits intomainfrom
luan.scroll
Apr 11, 2026
Merged

feat: Implement ScrollCallbacks on new event system#3892
luanpotter merged 4 commits intomainfrom
luan.scroll

Conversation

@luanpotter
Copy link
Copy Markdown
Member

Description

Following up on our events master plan.

This adds ScrollCallbacks and necessary infrastructure to make it work.

This replaces the old ScrollDetector (which we can deprecate later), e.g.:

class MyGame extends FlameGame with ScrollDetector {
  @override
  void onScroll(PointerScrollInfo info) {
    camera.moveBy(-info.scrollDelta.global);
  }
}

With ScrollCallbacks following the newer patterns in flame:

class ScrollableSquare extends RectangleComponent with ScrollCallbacks {
  @override
  void onScroll(ScrollEvent event) {
    final factor = event.scrollDelta.y > 0 ? 1.1 : 0.9;
    scale.scale(factor);
    event.continuePropagation = false;
  }
}

Also updates the example

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@luanpotter luanpotter force-pushed the luan.scroll branch 2 times, most recently from 102fd1d to 5cba925 Compare April 9, 2026 01:08
@luanpotter luanpotter marked this pull request as ready for review April 9, 2026 01:44
@luanpotter luanpotter requested a review from a team April 9, 2026 01:44
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, just some minor doc comments

@luanpotter luanpotter enabled auto-merge (squash) April 10, 2026 12:47
@luanpotter luanpotter merged commit d001003 into main Apr 11, 2026
72 checks passed
@luanpotter luanpotter deleted the luan.scroll branch April 11, 2026 15:37
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

Successfully merging this pull request may close these issues.

2 participants