79820745

Date: 2025-11-15 10:36:07
Score: 1
Natty:
Report link

When you use BlocProvider , it ctreates its own context. The context inside button is reffering to the TempScreen.

BlocProvider creates a new subtree, and the outer context does not contain the new provider. So context.read<TempScreenCubit>() is using the wrong BuildContext.

The correct context is the one inside the BlocProvider subtree, not the one from TempScreen’s build method.

Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When you use
  • Low reputation (1):
Posted by: Mohammad Ali Ghasemian