imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.87k stars 1.78k forks source link

DropdownMenu becomes unclickable with dynamically updated line charts #1558

Closed t123yh closed 10 months ago

t123yh commented 10 months ago

Describe the bug When the displayed page contains a line chart that's being constantly updated (like Line Chart Sample 10 in the example app), DropdownMenu entries become unclickable.

To Reproduce See this repo: https://github.com/t123yh/fl_chart/tree/main/example (official example with a little code added to demonstrate the bug)

Screenshots video

Versions

imaNNeo commented 10 months ago

Because your dropdown is defined at the same level of the widget tree that we rebuild 60 times per second. The solution is that define the dropDown as a top-level widget separate it from the 60 times rebuild.

Take a look at this code: https://gist.github.com/imaNNeo/0b373eff097faf7a9a33e37ad1707fef