首页 > 解决方案 > 如果 body 为空,如何停止在 nestedScrollView 中滚动

问题描述

有时我的 body 小部件有数据,有时没有,所以当 body 为空但无法修复时,我需要在 nestedScrollView 中停止滚动

NestedScrollView(
                //controller: model.scrollController,
                headerSliverBuilder: (context, innerScroll) {
                  return [
                    model.isShowToolbar
                        ? SliverAppBar(
                            pinned: true,
                            floating: false,
                          )
                        : SliverPadding(padding: const EdgeInsets.all(0.0)),
                    Container(
                      height: 200,
                      color: Colors.green,
                    )
                  ];
                },
                body: ErrorWidgetView(
                  lottieFile: 'assets/images/post_empty.json',
                  title: 'No Recent Post',
                  showButton: false,
                ),
              ),

标签: flutterdartflutter-sliver

解决方案


NotificationListener<ScrollNotification>(
                  onNotification: (ScrollNotification scrollInfo){
                    if ( !myModel.isLoading  &&scrollInfo.metrics.pixels ==
                        scrollInfo.metrics.maxScrollExtent) {
                    
                    }
                    return false;
                  },)

用户通知监听器


推荐阅读