0

I declared a BlocProvider in a class and used the Bloc Builder in the class below it, and it worked.

However, when using Navigator and declaring BlocBuilder in the child class of this child class and using the same Bloc declared above, an error occurred.

However, when declaring BlocProvider in the main method (above MaterialApp), you can use multiple BlocBuilders with only one BlocProvider at any layer.

I want to declare BlocProvider only once, use BlocBuilder in multiple places and share state. Is there no way other than the main method?

dontknowhy
  • 2,480
  • 2
  • 23
  • 67

1 Answers1

1

As per the documentation, wrap your home screen with the BlocProvider. You might also refer to this question, which seems relevant to your own question.

Tim Jacobs
  • 1,023
  • 1
  • 8
  • 14