Flutter NestedScrollView中ScrollOnExpand触发时异常滚动至顶部问题
问题:NestedScrollView中ScrollOnExpand触发时异常滚动到顶部
在NestedScrollView中使用Expandable包的ScrollOnExpand组件,原本是为了让展开的部件超出屏幕范围时能自动滚动展示完整内容,但遇到一个问题:当需要展开的部件位于屏幕上方区域时,触发ScrollOnExpand会导致页面直接滚动到顶部。
相关代码如下:
NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ SliverAppBar( expandedHeight: 200.0, flexibleSpace: FlexibleSpaceBar( title: Text('SliverAppBar'), ), pinned: true, ), ]; }, body: CustomScrollView( slivers: [ SliverList.builder( itemCount: 20, itemBuilder: (BuildContext context, int index) { return Container( key: ValueKey('test1 $index'), margin: EdgeInsets.all(30), color: Colors.grey, child: ExpandableNotifier( key: ValueKey('test2 $index'), child: ScrollOnExpand( key: ValueKey('test3 $index'), child: Column( key: ValueKey('test4 $index'), children: [ ExpandableTheme ( data:ExpandableThemeData( animationDuration: Duration(milliseconds: 1000), ), child: ExpandablePanel( key: ValueKey('test5 $index'), header: Text('test $index'), collapsed: Text('test collapsed $index'), expanded: SizedBox(height:100,child: Text('test expanded $index')), ), ), ExpandableButton(child: Text('button $index') ,) ], ), ), ), ); }, ), ], ), )

曾在该包的代码仓库找到类似问题,但给出的解决方案无法解决当前问题。
内容的提问来源于stack exchange,提问作者Michel Wang
相关产品推荐
相关产品推荐

