Closed raulmabe closed 4 years ago
Hi @Rahuvich 👋 Thanks for opening an issue!
Can you please share a link to a sample app which illustrates the problem you’re seeing? Thanks! 👍
Nevermind, the issue was I was calling MediaQuery.of(context) inside the create BlocProvider :sweat_smile: I thought it was a BLoC provider issue, but nope!
Thank you @felangel anyway for your great support to this library and to open source projects, Your presentation in Europe was very useful to us, newbies to BLoC :clap:
Just wanted to understand. why calling MediaQuery.of(context) inside creating the bloc is throwing the error. As I understand the context is BuildContext, which will have the access of the screen params. Calling it should work. rit?
BlocProvider(
create: (context) {
Map args = ModalRoute.of(context).settings.arguments;
return getIt<BaseBloc>()..add(BaseEvent.networkListeningInitiated()),
})
As in this code trying to access the args is also throwing the same error.
Hi @sidy-refyne 👋
You're getting that error simply because the inherited widget has no way of notifying the changes inside create
since create
is only called once, so basically it's an improper use of it.
You still may create a bloc with context, just make sure not to pass the Build context from the create method, but from previous methods.
create: (_) => ClockScreenBloc(state, context)
Hello, I am coming from redux and I am learning how to use the BLoC pattern using
flutter_bloc: ^6.0.1
.I am implementing an infinite list following this tutorial (with custom models) and I am getting the following error:
The error is thrown when trying to paint MainPage widget, which is the following widget:
When this widget is removed from the tree, the app does not crash. As I am new to BLoC, and also new to Provider, I can't find where is the bug. Any hint on the case will be highly appreciated.