hnvn/flutter_flip_panel

FlipPanel.stream not updating properly when using a ticker provider mixin

cnsumner opened this issue · 2 comments

It's possible that I'm just completely failing to use streams correctly, but I think this might actually be a bug.

Expected behavior: FlipPanel increments up by 1 every 2 seconds. Ticker drives animation controller, using a status listener to update an integer and adding it to the stream (calling setState appropriately) every time the duration ends (also restarts AnimationController), every 2 seconds. Flip panel receives each new number as it is added to the StreamController, and updates accordingly

Actual behavior: All of the above happens (the counter updates correctly and everything) except the FlipPanel flips... and shows the same number over and over. However if the FAB (also hooked up to update the counter) is pressed, the Flip panel suddenly jumps to the correct number before continuing to show that new number over and over until the button is pressed enough.

I have a larger app having this issue, but I have reduced it down to a basic flutter app with a single FlipPanel to demonstrate the bug and hopefully this code will help others replicate it. Here is a gist of the main dart file: https://gist.github.com/cnsumner/fc96857beb33429629821fb7a3ff3fd0

Just create a new flutter app and paste that code into the dart file (and add flip_panel: ^0.0.9 to your pubspec of course).

Any help would be appreciated, I'm going crazy trying to fix this.

hnvn commented

I've had a look at your codes, my suggestion is that remove setState from your codes, you just need increase counter and add it to StreamController and FlipPanel will be triggered

Sure enough, that did the trick, thank you! Meant to reply a few days ago, but got sidetracked and totally forgot.