Flutter: ListView disable scrolling with touchscreen

FlutterDartListviewDisable

Flutter Problem Overview


Is it possible to let a ListView only be scrollable with the ScrollController and not with the touchscreen?

Flutter Solutions


Solution 1 - Flutter

As mentioned in the comments, the NeverScrollableScrollPhysics class will do this:

> NeverScrollableScrollPhysics class > > Scroll physics that does not allow the user to scroll.

Solution 2 - Flutter

Inside ListView widget, use

physics: const NeverScrollableScrollPhysics()

Solution 3 - Flutter

You may add just primary: false inside your ListView Widget

Defaults to matching platform conventions. Furthermore, if the primary is false, then the user cannot scroll if there is insufficient content to scroll, while if the primary is true, they can always attempt to scroll.

For more, check out Official Doc

Solution 4 - Flutter

Conditional statement for enable and disable scrollview.

physics: chckSwitch ? const  NeverScrollableScrollPhysics() : const AlwaysScrollableScrollPhysics(),

Solution 5 - Flutter

Worked for me

 ListView.builder(
    scrollDirection: Axis.vertical,
    shrinkWrap: true,
    physics: const ClampingScrollPhysics(),
...

Solution 6 - Flutter

what about NestedScrollView ?

            bottomNavigationBar: _buildBottomAppBar(),
            body: Container(
              child: NestedScrollView(
                physics: NeverScrollableScrollPhysics(),
                controller: _scrollViewController,
                headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
                  return <Widget>[                    buildSliverAppBar(innerBoxIsScrolled),                  ];
                },
                body: _buildBody(context),
              ),
            ),
          );

it's working for me

Solution 7 - Flutter

You can achieve this by two ways

  1. If you just want to disable scrolling entirely screen

    Then solution is to wrap the ListView in an IgnorePointer widget.

  2. And you can also disable scrolling only on your ListView like this

    set the shrinkWrap: true and primary: true property on the ListView, which will disable scrolling:

    ListView(
      shrinkWrap: true,
      primary: true,
    

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTobias GuboView Question on Stackoverflow
Solution 1 - FlutterDanny TuppenyView Answer on Stackoverflow
Solution 2 - FlutterAnkur KediaView Answer on Stackoverflow
Solution 3 - FlutterMital JoshiView Answer on Stackoverflow
Solution 4 - FlutterFerer AtlusView Answer on Stackoverflow
Solution 5 - FlutterShiru99View Answer on Stackoverflow
Solution 6 - FlutterThinh NguyenView Answer on Stackoverflow
Solution 7 - FlutterParesh MangukiyaView Answer on Stackoverflow