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

Comments

@CosmicPangolin
Copy link

commented Jun 1, 2019

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

This comment has been minimized.

Copy link
Owner

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 label Jun 2, 2019

@felangel felangel added this to In progress in bloc Jun 2, 2019

@felangel felangel referenced this issue Jun 2, 2019

Merged

Fix null previousState in BlocBuilder condition #329

3 of 3 tasks complete
@felangel

This comment has been minimized.

Copy link
Owner

commented Jun 2, 2019

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

@felangel felangel closed this 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
Projects
2 participants
You can’t perform that action at this time.