Skip to content

fix: Bloc instance was null on initial state#3921

Open
erickzanardo wants to merge 1 commit into
mainfrom
fix/bloc-instance-on-on-mount
Open

fix: Bloc instance was null on initial state#3921
erickzanardo wants to merge 1 commit into
mainfrom
fix/bloc-instance-on-on-mount

Conversation

@erickzanardo
Copy link
Copy Markdown
Member

@erickzanardo erickzanardo commented May 13, 2026

Description

Fixes: #3918

In Flame, isMounted becomes true after onMount() finishes. But FlameBlocListenable calls onInitialState() inside onMount(), so when the user accesses this.bloc there, the getter checks isMounted — which is still false, triggering the assertion. The bloc is already resolved, just not considered "mounted" yet.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

@erickzanardo erickzanardo marked this pull request as draft May 13, 2026 13:21
@erickzanardo erickzanardo marked this pull request as ready for review May 13, 2026 14:11
@erickzanardo erickzanardo requested a review from a team May 14, 2026 01:57
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

Successfully merging this pull request may close these issues.

flame_bloc cannot access bloc in onInitialState

1 participant