Implement Abstract Class for Bloc, Injectables and getIt

32 views Asked by At

How do I implement this code - using the Concrete class OnBoardingCategoriesProvider using get_it and injectables I have

BlocProvider<StepperBloc>(
  create: (context) => StepperBloc(
      CategoriesStepperController(OnBoardingCategoriesProvider())),
),

I am attempting to use getIt like this

@lazySingleton
class StepperBloc extends Bloc<StepperEvent, StepperState> {
     final CategoriesStepperController stepperController;

     StepperBloc({required this.stepperController})
}




@lazySingleton
class CategoriesStepperController {
  final CategoriesProvider _categoryProvider;
   CategoriesStepperController(this._categoryProvider)

abstract class CategoriesProvider {
  final List<OnBoardingCategory> categories;

  const CategoriesProvider(this.categories);
}


@Named("OnBoardingCategoriesProvider")
@Injectable(as: CategoriesProvider)
class OnBoardingCategoriesProvider extends CategoriesProvider {
  OnBoardingCategoriesProvider()
      : super([
          MyCategory(),
        ]);
 }

But I do not know how to call it using OnBoardingCategoriesProvider. I do not know the syntax

BlocProvider<StepperBloc>(
   create: (context) => getIt<StepperBloc>(),
),
0

There are 0 answers