Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad state: add Fetch Article was called without a registered event handler

Tags:

flutter

class _HomePageState extends State<HomePage> {
  late ArticleBloc articleBloc;

  @override
  void initState() {
    super.initState();
    articleBloc = BlocProvider.of<ArticleBloc>(context);
    articleBloc.add(FetchArticlesEvent());
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

It works before but now the code wasn't working.

I try a lot to search but I failed.

This is the error:

Bad state: add(FetchArticlesEvent) was called without a registered event handler.

like image 535
Kissiney Sweet Avatar asked Dec 23 '25 00:12

Kissiney Sweet


1 Answers

What is your bloc version? Maybe you are using v8.0.0

At the mention here. and the author's proposal for replacement.

In bloc v7.2.0, mapEventToState was deprecated in favor of on. mapEventToState will be removed in bloc v8.0.0.

So please check your bloc version

like image 185
dangg Avatar answered Dec 24 '25 22:12

dangg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!