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

Limpar o state atual da Store. #121

Open
gabrielgiovans opened this issue Sep 9, 2024 · 1 comment
Open

Limpar o state atual da Store. #121

gabrielgiovans opened this issue Sep 9, 2024 · 1 comment

Comments

@gabrielgiovans
Copy link

Describe the bug
Criei um controller que é um singleton para ter alguns controles sobre o ticket selecionado pelo usuário. Porém quando quero limpar o mesmo passando null, ele acaba me retornando o state antigo.

To Reproduce

class TicketController extends Store<TicketEntity?>{
  TicketController() : super(null);

  Future<void> setSelectedTicket(TicketEntity? ticket) async {
    try {
      setLoading(true);
      update(ticket, force: true);
    } catch (e) {
      setError(e);
    }
  }

Expected behavior
ao chamar setSelectedTicket(null), deveria por o state atual como nulo, mas ele acaba mantendo o mesmo state.

O motivo está no copyWith feito no update().

Screenshots
image

@gabrielgiovans
Copy link
Author

up

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

1 participant