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

Can't setState on onTrackballPositionChanging #21

Closed
sandycurrie opened this issue Sep 10, 2019 · 7 comments
Closed

Can't setState on onTrackballPositionChanging #21

sandycurrie opened this issue Sep 10, 2019 · 7 comments

Comments

@sandycurrie
Copy link

Hi, I've been really enjoying working with this library. I have only come across one issue, when I try to use the onTrackballPositionChanging (or any other UI event handler), I get exceptions, because it doesn't like that I am trying to save the currently selected point to state with setState().
I've done some reading, and this is not recommended by the flutter team on: https://api.flutter.dev/flutter/widgets/CustomPaint-class.html

Because custom paint calls its painters during paint, you cannot call setState or markNeedsLayout during the callback (the layout for this frame has already happened).

Is there any way that these UI event handlers like onTrackballPositionChanging could be called from somewhere else? otherwise, I don't even know what I could use these events for...

@whenislunch
Copy link

second this

@dharanidharandharmasivam
Copy link
Contributor

Hi @sandycurrie ,

We regret the delay. We can replicate the reported issue while setState is called in onTracballPositionChanging event. So, we have considered this as a bug at our end, we will fix this issue and publish it in our upcoming update. We appreciate your patience until then. We will let you know once we have published.

Thanks,
Dharani.

@dharanidharandharmasivam
Copy link
Contributor

Hi @sandycurrie ,

Thanks for being patience. The reported issue has been fixed, now exception will not be thrown when setState is called in onTrackballPositionChanging event. To resolve the reported issue, kindly upgrade your packages from the below link.

https://pub.dev/packages/syncfusion_flutter_charts

Thanks,
Dharani.

@rrrobinnn
Copy link

Hi, when using setState inside onTrackballPositionChanging, the trackball is visible anymore.

I used your example which was posted here. This example worked fine, but when I simply added setState(() {}); inside onTrackballPositionChanging, the trackball disappeared

I updated the example to the most recent syncfusion version 18.3.48+1

@Jamesmallon1
Copy link

Hi there,

Just to chase on this issue as its holding up development on our end.

We use trackball within our charts but also use onTrackballPositionChanging to relay the current plot on the graph to the parent view to display the values on the chart as headers. On using setState or notifyListeners (from provider) during this method the trackball line disappears and never appears again despite the values being relayed correctly.

I have tried to use select from provider to only listen to specific changes but the trackball still disappears. Additionally I am building the chart as part of a separate class but despite trying a huge amount as long as setState or notifyListeners is called in any parent widget whilst the trackball is displayed it will disappear.

This is obviously less than ideal, is there another solution or a workaround for now?

@fpferrer
Copy link

fpferrer commented Oct 3, 2023

Hi @Jamesmallon1 ,

I am having the same problem, were you able to solve it?

@HenrikSunvigo
Copy link

HenrikSunvigo commented Nov 15, 2023

Any updates on this? Still having the same issue

edit:
if someone else is running into the same issue, try to use ValueNotifier to update the displayed value, this one works for me replacing the setState.

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

8 participants