I have created a Flutter Cubit class that has a method that create an object of itself, the problem is when I try to create a variable of this class with this method I get a type error, so what is the solution?
class AppCubit extends Cubit<AppStates>{
AppCubit ():super(AppIntialState());
static AppCubit get(context) => BlocProvider.of(context);
I tried to call this method with context, but I get the type error.
AppCubit cubit= AppCubit.get(context);
2
Answers
Probably you need to provide the generic type, try changing this
to this
Try like this:
You need to use
BuildContext
context inside get() or simply