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

Bloc instance becomes null when emitting state from callback in Dio sync case method #2392

Closed
skkeskar2000 opened this issue Mar 31, 2025 · 1 comment

Comments

@skkeskar2000
Copy link

I’m encountering an issue in my Flutter app where the Bloc instance becomes null when emitting a state from a callback in Dio’s syncCase method. The listener triggers successfully, but the BlocBuilder does not rebuild the UI as expected.

Steps to Reproduce:

  1. Set up a sync case method using Dio to upload data in the Flutter app.
  2. Use a BlocConsumer and BlocBuilder to listen for state changes and rebuild the UI.
  3. Emit a state from a callback in the Dio request, triggering a listener.
  4. Observe that the listener works, but the BlocBuilder does not rebuild, and the Bloc instance is null when emitting the state.

Expected Behavior:
The BlocBuilder should rebuild the UI when a new state is emitted, even if the emission happens inside a callback.

Actual Behavior:
The listener triggers, but the BlocBuilder does not rebuild the UI, and the Bloc instance becomes null when emitting the state.

TestResponse response = await testRepo.syncCase(syncCaseModel, caseToSync.patientId, (send, total) {
  double overallFractionListener was triggered;
  progress = overallFraction * 10000;
  emit(SyncCaseUploading(total: total, currentUploading: uploading, progress: progress));
});

Copy link
Contributor

@skkeskar2000 Infra and blank issues are only available for moderators. You're apparently using the wrong issue template.

Infra 和空白 issue 仅供管理人员使用,请选择其他 issue 模板创建 issue。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 31, 2025
@github-actions github-actions bot locked as off-topic and limited conversation to collaborators Mar 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant