Refresh indicator without scrollview

后端 未结 8 1033
失恋的感觉
失恋的感觉 2020-12-14 15:52

I know with a ListView or SingleChildScrollView RefreshIndicator just works natively but I want to use a RefreshIndicator

相关标签:
8条回答
  • 2020-12-14 16:39

    Recommend using AlwaysScrollableScrollPhysics() with RefreshIndicator because If the Scrollable might not have enough content to over-scroll, consider settings its physics property to AlwaysScrollableScrollPhysics.

    Instead of creating your own subclasses, parent can be used to combine ScrollPhysics objects of different types to get the desired scroll physics. For example:

    ListView(
      physics: const AlwaysScrollableScrollPhysics(),
      children: ...
    )
    

    Note : A RefreshIndicator can only be used with a vertical scroll view.

    0 讨论(0)
  • 2020-12-14 16:44

    In ListView.builder use physics: AlwaysScrollableScrollPhysics()

    Example:

    RefreshIndicator(
       onRefresh: () => _onRefresh(),
       child: Center(
                child: ListView.builder(
                         physics: AlwaysScrollableScrollPhysics(),
                          controller: _scrollController,
                          itemCount: 4,
                          addAutomaticKeepAlives: true,
                          itemBuilder: (BuildContext context, int position) {
                                return Text("Hello $position");
                              }
                  ),
          ),
    )
    
    0 讨论(0)
提交回复
热议问题