Open ramirezsebas opened 1 year ago
@ramirezsebas I believe the issue here has to do with the fact that you're injecting the repository manually, and you're calling getit
why not mark your block as injectable as well and have injectable build the whole thing?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions
This is my flutter doctor
I am using:
I've designed an abstract class that serves as a repository within my app. To implement this repository, I've created a concrete implementation that adheres to the methods defined in the abstract class, ensuring a consistent contract for data operations. Additionally, I'd like to mention that I am injecting the repository into my Cubit, where the Cubit acts as a state management solution.
abstract class MyBaseRepository{}
@Injectable(as: MyBaseRepository) class MyRepository implements MyBaseRepository{}
Everything works perfectly, but when I add @Named("api") @Named("Api") @Injectable(as: MyBaseRepository) class MyRepository implements MyBaseRepository{}
class MyCubit extends Cubit {
final MyRepository _westernUnionRepository;
MyCubit(@Named('Api') this._westernUnionRepository) : super(MyInitial()); }
BlocProvider( create: (context) => MyCubit( getItInjector(),
),
child: const MyView(),
);
I get the following error: Bad state: GetIt: Object/factory with type MyRepository is not registered inside GetIt. (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance; Did you forget to register it?)
I have followed the instructions in the documentation