Reputation: 33
What's the difference providing to a bloc parameter an object and a class, for example:
BlocProvider<AuthBloc>(
bloc: AuthBloc(),
child: Child()
);
from:
_authBloc = BlocProvider.of<AuthBloc>(context);
BlocProvider<AuthBloc>(
bloc: _authBloc,
child: Child()
);
Thanks :), i hope you can help a lot of people with this doubth.
Upvotes: 1
Views: 378
Reputation: 11481
BlocProvider(
bloc: AuthBloc(),
child: Child()
);
In this case, you are creating a new instance of AuthBloc and passing it into the BlocProvider
.
_authBloc = BlocProvider.of<AuthBloc>(context);
BlocProvider<AuthBloc>(
bloc: _authBloc,
child: Child()
);
In this case, you are not creating any new instance, instead fetching the previously created instance from the above tree using BlocProvider.of<AuthBloc>(context);
Upvotes: 2