xuelongqy / flutter_easy_refresh

A flutter widget that provides pull-down refresh and pull-up load.
https://xuelongqy.github.io/flutter_easy_refresh/
MIT License
3.88k stars 633 forks source link

_AssertionError ('package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart': Failed assertion: line 1760 pos 9: 'result': is not true.) #652

Open RezaKhajvand opened 1 year ago

RezaKhajvand commented 1 year ago

i used extended nested scrollview with easy refresh but i have some issues.one of them is (_AssertionError ('package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart': Failed assertion: line 1760 pos 9: 'result': is not true.)) when i pull down page to refresh and then scrolling down cause this issue but not every time...(1 time in 5 try). the app is not crashing and i dont have any issu in performance but i want to know how can i handle this issue and it can cause proble in my project or not? thanks @xuelongqy @fluttercandies

https://user-images.githubusercontent.com/120022216/206173224-d9df0ae8-2940-495c-8e59-ddbc97f26341.mp4

`import 'dart:async';

import 'package:example/widget/skeleton_item.dart'; import 'package:flutter/material.dart'; import 'package:easy_refresh/easy_refresh.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:get/get.dart';

class TabBarViewPage extends StatefulWidget { const TabBarViewPage({Key? key}) : super(key: key);

@override TabBarViewPageState createState() { return TabBarViewPageState(); } }

class TabBarViewPageState extends State with SingleTickerProviderStateMixin { late TabController _tabController; int _listCount = 20; int _gridCount = 20;

@override void initState() { super.initState(); _tabController = TabController(length: 2, vsync: this); }

@override void dispose() { super.dispose(); _tabController.dispose(); }

@override Widget build(BuildContext context) { final themeData = Theme.of(context); return Scaffold( body: EasyRefresh.builder( header: ClassicHeader( clamping: true, position: IndicatorPosition.locator, mainAxisAlignment: MainAxisAlignment.end, dragText: 'Pull to refresh'.tr, armedText: 'Release ready'.tr, readyText: 'Refreshing...'.tr, processingText: 'Refreshing...'.tr, processedText: 'Succeeded'.tr, noMoreText: 'No more'.tr, failedText: 'Failed'.tr, messageText: 'Last updated at %T'.tr, ), footer: ClassicFooter( position: IndicatorPosition.locator, dragText: 'Pull to load'.tr, armedText: 'Release ready'.tr, readyText: 'Loading...'.tr, processingText: 'Loading...'.tr, processedText: 'Succeeded'.tr, noMoreText: 'No more'.tr, failedText: 'Failed'.tr, messageText: 'Last updated at %T'.tr, ), onRefresh: () async { await Future.delayed(const Duration(seconds: 2), () { if (mounted) { setState(() { if (_tabController.index == 0) { _listCount = 20; } else { _gridCount = 20; } }); } }); }, onLoad: () async { await Future.delayed(const Duration(seconds: 2), () { if (mounted) { setState(() { if (_tabController.index == 0) { _listCount += 10; } else { _gridCount += 10; } }); } }); }, childBuilder: (context, physics) { return ScrollConfiguration( behavior: const ERScrollBehavior(), child: ExtendedNestedScrollView( physics: physics, onlyOneScrollInBody: true, pinnedHeaderSliverHeightBuilder: () { return MediaQuery.of(context).padding.top + kToolbarHeight; }, headerSliverBuilder: (context, innerBoxIsScrolled) { return [ const HeaderLocator.sliver(clearExtent: false), SliverAppBar( expandedHeight: 300, pinned: true, bottom: PreferredSize( preferredSize: Size.fromHeight(70), child: TabBar( controller: _tabController, labelColor: themeData.colorScheme.primary, indicatorColor: themeData.colorScheme.primary, tabs: const [ Tab( text: 'List', ), Tab( text: 'Grid', ), ], ), ), ), ]; }, body: TabBarView( controller: _tabController, children: [ ExtendedVisibilityDetector( uniqueKey: const Key('Tab0'), child: _AutomaticKeepAlive( child: CustomScrollView( physics: physics, slivers: [ SliverList( delegate: SliverChildBuilderDelegate((context, index) { return const SkeletonItem(); }, childCount: _listCount)), const FooterLocator.sliver(), ], ), ), ), ExtendedVisibilityDetector( uniqueKey: const Key('Tab1'), child: _AutomaticKeepAlive( child: CustomScrollView( physics: physics, slivers: [ SliverGrid( delegate: SliverChildBuilderDelegate((context, index) { return const SkeletonItem( direction: Axis.horizontal, ); }, childCount: _gridCount), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 6 / 7, )), const FooterLocator.sliver(), ], ), ), ), ], ), ), ); }, ), ); } }

class _AutomaticKeepAlive extends StatefulWidget { final Widget child;

const _AutomaticKeepAlive({ Key? key, required this.child, }) : super(key: key);

@override State<_AutomaticKeepAlive> createState() => _AutomaticKeepAliveState(); }

class _AutomaticKeepAliveState extends State<_AutomaticKeepAlive> with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { super.build(context); return widget.child; }

@override bool get wantKeepAlive => true; } `

xuelongqy commented 1 year ago

This problem does exist, but I don't know how to fix it. It doesn't seem to have much impact on usage

RezaKhajvand commented 1 year ago

This problem does exist, but I don't know how to fix it. It doesn't seem to have much impact on usage

no it doesnt impact on usage...i tryed this package with nestedscroll view and tabbar in the bottom of sliverappbar...the output is just like the output of extendedscrollview with the same warning but i prefer to use nestedscrollview cause i can use sliver absorber and injector.and with just customscrollview in the tabbarview we dont get overlap issue when pulling down to refresh with sliverappbar that has bigger expanded height. by the way tnx alot for youre package...its exactly what i need. hope its get better and better.

SeeYouWilsen commented 1 year ago

I have the same issues

SeeYouWilsen commented 1 year ago

This problem does exist, but I don't know how to fix it. It doesn't seem to have much impact on usage

这个问题会导致页面在滑动的时候卡顿

chenfasheng commented 8 months ago

同样的问题,示例代码无修改。

fallenleavesguy commented 2 months ago

我提供复现demo,悬赏小100块,直到有人解决

fallenleavesguy commented 2 months ago

我提供复现demo,悬赏小100块,直到有人解决

解决办法就是把assert全干掉。