Skip to content

State of the cards synchronization problem in the bloc and widget #11

Open
@konstantin-doncov

Description

@konstantin-doncov

Hello, I faced a problem when used your cards(Gesture detector and Alignment type) with bloc.

If you want more details I think it will be better for you to check my original code. Also, here is the original issue in the bloc repository

I need to keep card which is in the process of removing(when card goes beyond the screen), because animation requires this instance. So I keep it in the special var deletingCard in the state. When animation is finished it resets this var to null.
But here is a problem. When new cards are loaded in the bloc I add them in the state and copy previous deletingCard var in the new state which I will yield:

yield GameDeckLoadedState(state.isNeedToAnimate, state.deletingCard, result);

But there is a delay between sending and receiving the state, so during the sending the deletingCard variable is not equal to null(for example, it's not always so) and we copy it to the new state, and when receiving the state the animation is already completed and the variable of old state is reset to null in the widget, but in the new state it is not so and the variable is not null.

As I understand, the animation is constantly rebuilding the widget while it removes the card.
So the situation is also possible when the last update of the widget occurs during the removal of the card, and during this comes a new state with a variable not equal to zero. The animation ended and the variable was reset, but a new state with a non-null variable returned this card back to the deck.

That is why the delay, which I specifically added, added and removed the problem with the different values.

Regards!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions