Skip to content

BlocBuilder condition bug - _previousState == null #328

@CosmicPangolin

Description

@CosmicPangolin

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions