Bloc: Help With BlocBuilder Compile Issue doesn't conform to the bound

Created on 11 Jun 2020  路  3Comments  路  Source: felangel/bloc

Starting out with bloc but having problems following. Why does this code
agapa_screen.dart

class AgapeScreen extends StatefulWidget {
  @override
  _AgapeState createState() => _AgapeState();
}

class _AgapeState extends State<AgapeScreen> {
@override
  Widget build(BuildContext context) {
     return BlocBuilder<AgapeBloc, Agape>(
      builder: (context, agape) {
        return Container();
      }
    );
  }
}

say Error: Type argument 'AgapeBloc' doesn't conform to the bound 'Bloc' of the type variable 'B' on 'BlocBuilder'.

The following are my code.

agape.dart

class Agape {

  String id;
  Agape();
}

and

agape_bloc.dart

class AgapeBloc extends Bloc<AgapeEvent, Agape> {

  @override
  Agape get initialState => Agape();

  @override
  Stream<Agape> mapEventToState(AgapeEvent event) async* {
    switch (event) {
      case AgapeEvent.get:
        break;
      case AgapeEvent.put:
        break;
    }
  }

}

enum AgapeEvent { get, put }
question

Most helpful comment

This was my mistake. im closing this. this was due to my naming of the screen and model having the same names.

All 3 comments

Hi @chitgoks 馃憢
Thanks for opening an issue!

Are you able to provide a link to a sample app which illustrates the issue? It would be much easier for me to help if I can reproduce the issue locally, thanks! 馃憤

hi felix thank you for reaching out. ill try, i havent tried putting this up remotely. it's a compile issue. you can copy the same code in dart files.

i added the widget class and edited the Agape class to remove the interface. so these can be copied and pasted manually as well.

This was my mistake. im closing this. this was due to my naming of the screen and model having the same names.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MahdiPishguy picture MahdiPishguy  路  3Comments

komapeb picture komapeb  路  3Comments

craiglabenz picture craiglabenz  路  3Comments

Reidond picture Reidond  路  3Comments

clicksocial picture clicksocial  路  3Comments