0
class _GridViewContentState extends State<GridViewContent> {
  final likeBloc= LikeBloc();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
    

while i comment bloc initialisation it goes away and works. Is there is any convention for initialising bloc pattern

A.K.J.94
  • 492
  • 6
  • 14
  • What errors do you get? – EdYuTo Dec 12 '20 at 07:31
  • i have a like button when click onPressed: () { likeBloc.mapLikeEvents(LikeEvent(snapshot.data.data.posts[widget.index].id)); } – A.K.J.94 Dec 12 '20 at 07:35
  • and then void mapLikeEvents(LikeEvents events)async{ if(events is LikeEvent){ ObjectFactory().repository.likePost(events); } else return; } then I get Stack overflow error – A.K.J.94 Dec 12 '20 at 07:36
  • I mean, can you edit the post with a stack trace or add more details about the exception you're getting? – EdYuTo Dec 12 '20 at 07:38
  • no it return only this much ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════ Stack Overflow ════════════════════════════════════════════════════════════════════════════════════════════════════ – A.K.J.94 Dec 12 '20 at 07:44
  • if i press one more time it will changes to another one ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════ The method 'mapLikeEvents' was called on null. Receiver: null Tried calling: mapLikeEvents(Instance of 'LikeEvent') ════════════════════════════════════════════════════════════════════════════════════════════════════ – A.K.J.94 Dec 12 '20 at 07:46
  • well i called a likebloc function inside of a StreamBuilder( ..... is it this is the reason? while I call userBloc from it no error occurs – A.K.J.94 Dec 12 '20 at 08:05
  • did you initialize bloc? – John Joe Dec 12 '20 at 09:10

0 Answers0