I've HomeBloc
from HomeView
class. Basic UI architecture is as following:
HomeView extends StatelessWidget {
BlocProvider( child: HomeBody(), bloc: new HomeBloc() )
}
HomeBody extends StatefulWidget {
createState => HomeBodyState()
}
HomeBodyState extends State {
BlocBuilder(
bloc: BlocProvider.of<HomeBloc>()
child: Container(
child: Column(
children: [
BlocProvider( child: CashFlowView, bloc: new HomeBloc() )
]
)
)
)
}
CashFlowView extends StatefulWidget {
createState => CashFlowState()
}
CashFlowState extends State {
BlocBuilder(
bloc: BlocProvider.of<HomeBloc>()
child: Container(
child: Column(
children: [
ChipGroupWidget(
onClick => BlocProvider.of().add(event) // <----- Problem is here
)
]
)
)
)
}
Whole code can be found in this repository.
Problem is when any Chip
inside my ChipGroup
is tapped, a callback function is called in CashFlowState
. Inside that, a bloc event is added to bloc with some data. But it is triggering only for first time. What's wrong in my code?