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

Observer throw exception using Computed value #44

Closed
copydog opened this issue Jan 17, 2019 · 2 comments
Closed

Observer throw exception using Computed value #44

copydog opened this issue Jan 17, 2019 · 2 comments

Comments

@copydog
Copy link
Collaborator

copydog commented Jan 17, 2019

I initialize a Computed value right before initialize my widget, Computed.value will throw an exception in Observer.
however Observable that just created would NOT.
If I initialize the Computed value long time before I initialize my widget, Computed.value will NOT throw an exception.

btw, I am using master branch, and I am using it in a real project.

here is the stacktrace:

flutter: # 0      Computed.value (file:///Users/shallow/Codes/dfe/db-app-flutter/packages/mobx/lib/src/core/computed.dart:81:7)
flutter: # 1      _ProfileCenterState._buildTop.<anonymous closure> (package:doubi/foundation/view/profile_center/profile_center.dart:149:66)
flutter: # 2      ObserverState.build (package:flutter_mobx/flutter_mobx.dart:46:21)
flutter: # 3      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
flutter: # 4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
flutter: # 5      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: # 8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 10     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
flutter: # 11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 12     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
flutter: # 13     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 14     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
flutter: # 15     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 16     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 17     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 18     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 19     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 20     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 21     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 22     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 23     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 24     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 25     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 26     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 27     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
flutter: # 28     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 29     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
flutter: # 30     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 31     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 32     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
flutter: # 33     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 34     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 36     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 37     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 38     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 40     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 41     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
flutter: # 42     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 43     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 44     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
flutter: # 45     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 46     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 47     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 48     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 49     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 50     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 51     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 52     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 53     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 54     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 55     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 56     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 57     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
flutter: # 58     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 59     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 60     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: # 61     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: # 62     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: # 63     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: # 64     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: # 65     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: # 66     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: # 67     SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1028:36)
flutter: # 68     SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1013:20)
flutter: # 69     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
flutter: # 70     SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1006:11)
flutter: # 71     RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:274:23)
flutter: # 72     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1730:58)
flutter: # 73     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:799:15)
flutter: # 74     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1730:13)
flutter: # 75     RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:263:5)
flutter: # 76     RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:341:5)
flutter: # 77     RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:78:12)
flutter: # 78     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 79     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
flutter: # 80     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 81     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:405:13)
flutter: # 82     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1316:12)
flutter: # 83     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1234:20)
flutter: # 84     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 85     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 86     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 87     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 88     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 89     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 90     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 91     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 92     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 93     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 94     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 95     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
flutter: # 96     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
flutter: # 97     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
flutter: # 98     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
flutter: # 99     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 100    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 101    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 102    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 103    _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11)
flutter: # 104    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 105    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 106    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 107    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 108    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 109    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 110    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 111    RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: # 112    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 113    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 114    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 115    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 116    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 117    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 118    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 119    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 120    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 121    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 122    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 123    RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2879:14)
flutter: # 124    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 125    RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: # 126    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 127    __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: post http://api.idoubi.top:18010/api-business/user/profile {code: 0, message: success, data: {id: 4, nickname: 哦~, avatarUrl: /images/usericon/4.png, wechatNumber: yay, credit: 100, signature: 这个人很懒,什么都没写。, country: 中国, province: 上海市, city: 上海市, gender: 2, remainder: 74013265, prize: 100, fanNumber: 1, friendNumber: 7, followNumber: 1, jgname: ocZI-2yXKmj3mPq2FC5FyNpMOL51}, time: 2019-01-17 12:14:59}
flutter: # 128    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 129    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 130    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 131    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 132    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 133    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 134    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 135    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 136    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 137    _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: # 138    RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: # 139    RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: # 140    RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: # 141    PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: # 142    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: # 143    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
flutter: # 144    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: # 145    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: # 146    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: # 147    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
flutter: # 148    _invoke (dart:ui/hooks.dart:154:13)
flutter: # 149    _drawFrame (dart:ui/hooks.dart:143:3)

Edit by @katis : quoted the stacktrace as it was accidentally referencing every issue we have

@copydog copydog changed the title Observer throw exception using Computed Observer throw exception using Computed value Jan 17, 2019
@pavanpodila
Copy link
Member

@copydog Its awesome that you are already trying out on a real project 👍

I suggest you create the computed-value outside of the build method. Ideally put the state in a separate class and use that class in the StatefulWidget. I should have an example soon.

@copydog
Copy link
Collaborator Author

copydog commented Jan 18, 2019

I did put computed-value outside the build method. It initialized Computed.value in the initState() of the State that using Observer. I will double check this exception and send a small example if located the problem (if there is any).

@copydog copydog closed this as completed Jan 18, 2019
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