like_button icon indicating copy to clipboard operation
like_button copied to clipboard

Strange async behaviour

Open zaidkazi opened this issue 3 years ago • 5 comments

Hey guys great library but a question when i run the like count and isLiked from a stream and have the onTap trigger a change in the value on a remote server it breaks the animation any suggestion

ontap: Future flameToggle(bool isLiked) async { await context .read<FIreStoreDB>() .myDB .setContentLiked(!isLiked)); return !isLiked; }

also i have the isLiked being set initially if liked or not from the stream

isLiked: mycontentModelStream.myContent.isLiked)

the values update but no animations

zaidkazi avatar Mar 25 '21 20:03 zaidkazi

Reading closed issues i see #43 also had this issue in a stream builder

zaidkazi avatar Mar 25 '21 20:03 zaidkazi

could you provide a simple runable demo? i can't see clearly with little code for this problem.

zmtzawqlp avatar Mar 26 '21 01:03 zmtzawqlp

Will try to create something! Thanks

zaidkazi avatar Mar 29 '21 15:03 zaidkazi

I had the same issue and this is how I solved it.

Don't set the "isLiked" value but instead use the "likeBuilder" to render the correct widget based on "like" or "unlike" state as determined by the stream you are using.

With this, whenever you "unlike" and "like" again, the animation will work.

"isLiked" is only set for "initial" rendering. So when the stream value changes, the whole "like_button" gets re-rendered vs just switching the "state" of like.

Infinitism avatar Aug 14 '22 20:08 Infinitism

I had the same issue and this is how I solved it.

Don't set the "isLiked" value but instead use the "likeBuilder" to render the correct widget based on "like" or "unlike" state as determined by the stream you are using.

With this, whenever you "unlike" and "like" again, the animation will work.

"isLiked" is only set for "initial" rendering. So when the stream value changes, the whole "like_button" gets re-rendered vs just switching the "state" of like.

"isLiked" is only set for "initial" rendering ---- yes, you are right

zmtzawqlp avatar Aug 15 '22 01:08 zmtzawqlp