Piinks · GitHub

Originally #75354

Design Document

This change applies Raw/Cupertino/Scrollbars by default on the Web and Desktop platforms. I've done this in a similar way to how we apply the GlowingOverscrollIndicator, in each Widget/Material/Cupertino ScrollBehavior. This allows us to get the right Scrollbar for the given ScrollBehavior.


This current proposal requires a breaking change to ScrollBehavior.buildViewportChrome, adding an optional controller parameter as Scrollbar requires a ScrollController for full functionality. Update: Instead I have deprecated buildViewportChrome in favor of buildViewportDecoration. Breaking the former was a really hard break, so I have introduced a new method, and added an opt-in flag (ScrollBehavior.useDecoration) so customers can be migrated gracefully.

This new method will use (also new) ScrollableDetails to ascertain the right decoration. Passing ScrollableDetails will be a bit more future-proof, where if needed we can add to the details rather than needing to change a function signature. The ScrollableDetails currently contains the required AxisDirection (used for the GlowingOverscrollIndicator decoration), and an optional controller. If a controller is not provided, no Scrollbar will be created.


Some instances of Scrollable are excluded from this including:

  • EditableText
  • ListWheelScrollView
  • PageView
  • NestedScrollView
  • Dropdown menus (they have their own ScrollBehavior that I have, for now, excluded scrollbars from)

To give users control over this, I have added the ability to toggle this feature on and off in ThemeData and CupertinoThemeData. Update: This was a bit over the top, exposing ScrollBehaviors is a cleaner way for users to control defaults. That will be a prerequisite change, in #76739


Blocked by: #76739

Fixes: #40107
Fixes: #70866 (Last part)
Also related as part of ScrollBehavior overhaul: #75728

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Read the original on github.com ↗