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

BlocBuilder condition bug - _previousState == null #328

Closed
CosmicPangolin opened this issue Jun 1, 2019 · 2 comments
Closed

BlocBuilder condition bug - _previousState == null #328

CosmicPangolin opened this issue Jun 1, 2019 · 2 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@CosmicPangolin
Copy link

First off, thanks for including the condition :)

I think there's a bug in _BlocBuilderBaseState. If I initialize a BlocBuilder with a condition, previousState defaults to null even if the provided bloc has an existing state...so the listener built in _subscribe() necessarily throws a null error on the bloc's next state change (assuming you're using an operator on previousState).

I think this can be fixed by setting _previousState = widget.bloc.currentState in the initState() method...ie. same assignment as state.

@felangel
Copy link
Owner

felangel commented Jun 2, 2019

@CosmicPangolin thanks for catching this! I’ll have it fixed later today 👍

@felangel felangel self-assigned this Jun 2, 2019
@felangel felangel added the bug Something isn't working label Jun 2, 2019
@felangel felangel added this to In progress in bloc Jun 2, 2019
@felangel
Copy link
Owner

felangel commented Jun 2, 2019

Fixed in #329 and included in v0.15.1 of flutter_bloc.

@felangel felangel closed this as completed Jun 2, 2019
@felangel felangel moved this from In progress to Done in bloc Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
bloc
  
Done
Development

No branches or pull requests

2 participants