Bloc: Error: 'Bloc' doesn't extend 'Cubit<S>'

Created on 29 Oct 2020  路  2Comments  路  Source: felangel/bloc

flutter_bloc 6.0.6

I try to use BlocBuilder:

Widget build(BuildContext context) {
    return BlocBuilder<MovieBloc, MovieEvent>(builder: (context, state) {...});
}

MovieBloc:
class MovieBloc extends Bloc<MovieEvent, MovieState> ....

Received error:

'MovieBloc' doesn't extend 'Cubit<MovieEvent>'.
Try using a type that is or is a subclass of 'Cubit<MovieEvent>'.

Seems like problem in incompatibility implementation
class BlocBuilder<C extends Cubit<S>, S> extends BlocBuilderBase<C, S >
and
abstract class Bloc<Event, State> extends Cubit<State>
in flutter_bloc 6.0.6 and bloc 6.1.0 respectively

question

Most helpful comment

Yes, you are right, my mistake. Thanks.

All 2 comments

Hi @OZ79 馃憢
Thanks for opening an issue!

I think the issue is you're providing incorrect types to BlocBuilder. It should accept the bloc type and the state type:

Widget build(BuildContext context) {
    return BlocBuilder<MovieBloc, MovieState>(builder: (context, state) {...});
}

Hope that helps 馃憤

Yes, you are right, my mistake. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

1AlexFix1 picture 1AlexFix1  路  3Comments

abinvp picture abinvp  路  3Comments

ricktotec picture ricktotec  路  3Comments

nerder picture nerder  路  3Comments

shawnchan2014 picture shawnchan2014  路  3Comments