0

I've just upgraded Flutter from 2.2 to 2.5, but my web app is behaving differently. In 2.2 it was possible to scroll vertically in a SingleChildScrollView and horizontally in a TabBarView by dragging without additional code. Dragging doesn't do anything now.

I would like to revert to the original behaviour from 2.2. Dragging should scroll vertically and horizontally.

However, adding different ScrollPhysics to those two widgets does not have any effect. I have found solutions that recommend wrapping the widget in a GestureDetector. This leads to a lot boilerplate code. Is there any other way to do it?

2
  • You can revert back to the previous version of Flutter. Commented Sep 13, 2021 at 21:00
  • 1
    @Apealed Reverting to an old version forever is not a good idea. You would miss any future optimization and security updates. Commented Sep 18, 2021 at 11:59

1 Answer 1

4

Flutter 2.5 Summary

ScrollBehaviors now allow or disallow drag scrolling from specified PointerDeviceKinds. ScrollBehavior.dragDevices, by default, allows scrolling widgets to be dragged by all PointerDeviceKinds except for PointerDeviceKind.mouse.

// Set ScrollBehavior for an entire application. MaterialApp( scrollBehavior: MyCustomScrollBehavior(), // ... ); 
class MyCustomScrollBehavior extends MaterialScrollBehavior { // Override behavior methods and getters like dragDevices @override Set<PointerDeviceKind> get dragDevices => { PointerDeviceKind.touch, PointerDeviceKind.mouse, }; } 

Referrence: Documentation

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.