kirti
kirti

Reputation: 171

Not able to disable scrolling in SingleChildScrollView

I am using a SingleChildScrollView and when tapping on FormTextField in it, the keyboard appears and the scroll view is scrolled upwards. After dismissing the keyboard, I am still able to scroll the Scrollview manually. Can you please suggest any solution to disable the manual scrolling after FormTextField disappears.

Upvotes: 17

Views: 16408

Answers (3)

mabg
mabg

Reputation: 2090

In my case, when I put physics: NeverScrollableScrollPhysics() SingleChildScrollView can't be scrolled, but a scroll bar appears. If I use the scroll bar, the content is scrolled.

I need to hide the scroll bar:

ScrollConfiguration(
    behavior:
        ScrollConfiguration.of(context).copyWith(scrollbars: false),
    child: SingleChildScrollView(
        physics: const NeverScrollableScrollPhysics(),
        child: child,
    )),

Upvotes: 5

AnDong93Nt
AnDong93Nt

Reputation: 11

I think we have the same problem. I use two settings in singleChildScrollView

physics: NeverScrollableScrollPhysics(), reverse: true,

This solution is acceptable to me, I hope it is good for you.

Upvotes: -2

carlosx2
carlosx2

Reputation: 1835

You can use the following code in your singleChildScrollView.

physics: NeverScrollableScrollPhysics(),

It stops it from being able to scroll.

Upvotes: 51

Related Questions