Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Disable desktop scrollbars #524

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class GalleryApp extends StatelessWidget {
child: Builder(
builder: (context) {
return MaterialApp(
// By default on desktop, scrollbars are applied by the
// ScrollBehavior. This overrides that. All vertical scrollables in
// the gallery need to be audited before enabling this feature,
// see https://github.com/flutter/gallery/issues/523
scrollBehavior: const MaterialScrollBehavior().copyWith(scrollbars: false),
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, this problem also exists in the legacy Flutter gallery.

I'm missing some context here to really understand why this is the right fix. In particular, why do certain scrollables need to set primary or not, when it used to "just work" that they didn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, this problem also exists in the legacy Flutter gallery.

Yeah, I need to track that down too.

why do certain scrollables need to set primary or not, when it used to "just work" that they didn't.

Vertical scrollables automatically attach to the primary scroll controller if they aren't given a scroll controller. The auto-scrollbar stuff is new, and the gallery will need to be updated for it. It 'just worked' before because there wasn't a widget in the tree enforcing that a certain scroll controller only has one position attached. Since the ScrollBehavior on desktop is adding scrollbars now, the gallery crashes because the when the user tries to interact with the scrollbar, the scrollbar tries to use the scroll controller to change the position. Since more than one position is attached, it breaks.

There is a migration guide here: https://flutter.dev/docs/release/breaking-changes/default-desktop-scrollbars

I am also updating the assertion in the framework because I do think it is a little too aggressive right now.

restorationScopeId: 'rootGallery',
title: 'Flutter Gallery',
debugShowCheckedModeBanner: false,
Expand Down