Flutter: ListView disable scrolling with touchscreen

前端 未结 5 453
逝去的感伤
逝去的感伤 2020-12-24 00:11

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

相关标签:
5条回答
  • 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

    0 讨论(0)
  • 2020-12-24 01:00

    Conditional statement for enable and disable scrollview.

    physics: chckSwitch ? const  NeverScrollableScrollPhysics() : const AlwaysScrollableScrollPhysics(),
    
    0 讨论(0)
  • 2020-12-24 01:02

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

    NeverScrollableScrollPhysics class

    Scroll physics that does not allow the user to scroll.

    0 讨论(0)
  • 2020-12-24 01:02

    Worked for me

     ListView.builder(
        scrollDirection: Axis.vertical,
        shrinkWrap: true,
        physics: const ClampingScrollPhysics(),
    ...
    
    0 讨论(0)
  • 2020-12-24 01:05

    Inside ListView widget, use

    physics: const NeverScrollableScrollPhysics()
    
    0 讨论(0)
提交回复
热议问题