【问题标题】:ListView in SlidingUpPanel scrollSlidingUpPanel 中的 ListView 滚动
【发布时间】:2021-04-13 18:02:42
【问题描述】:

在slidingUpPanel 中,我有一个ListView 小部件。当我尝试滚动时,ListViewslidingUpPanel 关闭。如何在不关闭slidingUpPanel 的情况下滚动ListView?

SlidingUpPanel(
  controller: _panelController,
  maxHeight: _panelHeightOpen,
  minHeight: _panelHeightClosed,
  borderRadius: BorderRadius.only(
    topLeft: Radius.circular(50),
    topRight: Radius.circular(50),
  ),
  boxShadow: [
    BoxShadow(
      color: secondaryColor,
      spreadRadius: 1,
      blurRadius: 5,
      offset: Offset(0, -10), // changes position of shadow
    ),
  ],
  panelBuilder: (sc) => _summaryWidget(sc),
),

我的_summaryWidget

ListView(
  shrinkWrap: true,
  physics: const NeverScrollableScrollPhysics(),
  children: [
    Photos(),
  ],
)

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您还需要将 sc 放入 ListView 控制器中:

    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text("SlidingUpPanelExample"),
        ),
        body: SlidingUpPanel(
          panelBuilder: (ScrollController sc) => _scrollingList(sc),
          body: Center(
            child: Text("This is the Widget behind the sliding panel"),
          ),
        ),
      );
    }
    
    Widget _scrollingList(ScrollController sc){
      return ListView.builder(
        controller: sc,
        itemCount: 50,
        itemBuilder: (BuildContext context, int i){
          return Container(
            padding: const EdgeInsets.all(12.0),
            child: Text("$i"),
          );
        },
      );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      • 2021-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      相关资源
      最近更新 更多