late FiltersBloc filtersBloc; @override Widget build(BuildContext context){ filtersBloc = BlocProvider.of<FiltersBloc>(context); return ... } @override void dispose() { filtersBloc.dispatch(); super.dispose(); }