Bloc: BlocA and BlocB work with each other required

Created on 2 Mar 2020  路  2Comments  路  Source: felangel/bloc

Describe the bug

BlocProvider<BlocA>(
  create: (BuildContext context) => BlocA(BlocProvider.of<BlocB>(context)),
  child: BlocProvider<BlocB>(
    create: (BuildContext context) => BlocB(BlocProvider.of<BlocA>(context)),
    child: BlocProvider<BlocC>(
      create: (BuildContext context) => BlocC(),
      child: ChildA(),
    )
  )
)

How does BlocA and BlocB work with each other required?
The BlocProvider.of<BlocB>(context) not within a child

question

Most helpful comment

Hi @felangel
Thanks ,it probably should avoid circular dependencies, I migrate BlocProvider.of<BlocB>(context) to UI Page and add event to blocB after BlocAstate be generated.By my issue BlocB.add() is before yield BlocAState()

All 2 comments

Hi @zengzhengrong 馃憢
Thanks for opening an issue!

I'm not sure I understand the question but in general you should really avoid having circular dependencies like this. Are you able to provide a link to a sample app which illustrates the issue as well as provide more context? Thanks 馃憤

Hi @felangel
Thanks ,it probably should avoid circular dependencies, I migrate BlocProvider.of<BlocB>(context) to UI Page and add event to blocB after BlocAstate be generated.By my issue BlocB.add() is before yield BlocAState()

Was this page helpful?
0 / 5 - 0 ratings