Closed aswanath closed 6 months ago
As I found out that the issue is as follows: While in the first case as I am using cascade to add an event and in the widget subtree I am not using any BlocBuilder or Listeners, so the bloc is managing to not even create the instance and pass to the widget tree. And while I am calling this
BlocProvider.of<AccountsBloc>(context, listen: true).getAccountGroups
then only the tree is activated with bloc but that event I added at first is void and never called.
So, I solved this issue by adding lazy=true
inside the BlocProvider
which will anyway pass down the bloc even if it is not using anywhere.
I have given code like below. But the accountsGroup is of empty list as the FetchAccountGroups() event is not calling while debugged.
But if I change my code like this (assign bloc into a variable and pass to the bloc provider), it works perfectly fine. What will be the issue as I am not able to find it. Is it the issue with Flutter or with Bloc?
I will provide the bloc event also: