Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用get控制器刷新时,第一次下拉刷新由空视图到列表会报错,不影响使用。上拉加载不会报错 #579

Closed
chjsun opened this issue Jul 29, 2022 · 2 comments

Comments

@chjsun
Copy link

chjsun commented Jul 29, 2022

Obx(()=> EasyRefresh(
        onRefresh: () {
          controller.onRefreshList(sign);
        },
        onLoad: () {
          controller.onLoadList(sign);
        },
        controller: controller.refreshController,
        child: ListView.builder(
          itemCount: data.isEmpty ? 1 : data.length,
          itemBuilder: (BuildContext context, int position) {
            if (data.isEmpty) {
              return const NoDataView();
            }
            ElectronicOrderListModel model = data[position];
            return ElectronicOrderListCell(
                model: model,
                onClick: () {
                  Get.toNamed(OldRoutes.ElecContractorListPage, arguments: model)?.then((value) {
                    /// 刷新列表
                    controller.onSearchList();
                  });
                });
          },
        ))
)

ERROR:

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for FooterNotifier:
Build scheduled during frame.

While the widget tree was being built, laid out, and painted, a new frame was scheduled to rebuild the widget tree.

This might be because setState() was called from a layout or paint callback. If a change is needed to the widget tree, it should be applied as the tree is being built. Scheduling a change for the subsequent frame instead results in an interface that lags behind by one frame. If this was done to make your build dependent on a size measured at layout time, consider using a LayoutBuilder, CustomSingleChildLayout, or CustomMultiChildLayout. If, on the other hand, the one frame delay is the desired effect, for example because this is an animation, consider scheduling the frame in a post-frame callback using SchedulerBinding.addPostFrameCallback or using an AnimationController to trigger the animation.

When the exception was thrown, this was the stack: 
#0      WidgetsBinding._handleBuildScheduled.<anonymous closure> (package:flutter/src/widgets/binding.dart:756:9)
#1      WidgetsBinding._handleBuildScheduled (package:flutter/src/widgets/binding.dart:779:6)
#2      BuildOwner.scheduleBuildFor (package:flutter/src/widgets/framework.dart:2482:24)
#3      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4495:12)
#4      State.setState (package:flutter/src/widgets/framework.dart:1129:15)
#5      _ValueListenableBuilderState._valueChanged (package:flutter/src/widgets/value_listenable_builder.dart:182:5)
#6      _IndicatorListenable._onNotify (package:easy_refresh/src/notifier/indicator_notifier.dart:762:15)
#7      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:324:24)
#8      IndicatorNotifier._updateOffset (package:easy_refresh/src/notifier/indicator_notifier.dart:473:9)
#9      IndicatorNotifier._updateBySimulation (package:easy_refresh/src/notifier/indicator_notifier.dart:427:5)
#10     _ERScrollPhysics.createBallisticSimulation (package:easy_refresh/src/physics/scroll_physics.dart:361:20)
#11     ScrollPhysics.createBallisticSimulation (package:flutter/src/widgets/scroll_physics.dart:343:20)
#12     ScrollPositionWithSingleContext.goBallistic (package:flutter/src/widgets/scroll_position_with_single_context.dart:144:44)
#13     IdleScrollActivity.applyNewDimensions (package:flutter/src/widgets/scroll_activity.dart:157:14)
#14     ScrollPosition.applyNewDimensions (package:flutter/src/widgets/scroll_position.dart:623:15)
#15     ScrollPositionWithSingleContext.applyNewDimensions (package:flutter/src/widgets/scroll_position_with_single_context.dart:104:11)
#16     ScrollPosition.applyContentDimensions (package:flutter/src/widgets/scroll_position.dart:553:7)
#17     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1493:20)
#18     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1757:7)
#19     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
#20     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:504:19)
#21     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:892:13)
#22     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:370:5)
#23     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
#24     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1083:9)
#25     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:997:5)
#29     _invoke (dart:ui/hooks.dart:151:10)
#30     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#31     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
The FooterNotifier sending notification was: Instance of 'FooterNotifier'
====================================================================================================
➜  ~ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2022.1.4)
[✓] VS Code (version 1.69.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!
@chjsun
Copy link
Author

chjsun commented Jul 29, 2022

image

image

补充截图。然后问题出现后,footer就消失了。但是上拉加载功能还能触发。

@xuelongqy
Copy link
Owner

onRefresh和onLoad使用async和await试试看?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants