Skip to content

Como usar binds exportadas dentro do próprio módulo? #1001

@allanwolski

Description

@allanwolski

Atualmente o Modular não permite utilizar uma bind exportada dentro do próprio módulo, o que dificulta muito a estruturação de módulos do projeto.

class EventModule extends Module {
  @override
  List<Module> get imports => [
    AuthModule(),
  ];

  @override
  void exportedBinds(i) {
    i.addSingleton(EventListBloc.new);
  }

  @override
  void binds(i) {
    i.addLazySingleton(EventCreateBloc.new);
    i.addLazySingleton(EventDataSource.new);
    i.addLazySingleton<EventRepository>(EventRepositoryImpl.new);
  }
class EventCreateBloc extends Bloc<EventCreateEvent, EventCreateState> {
  final EventListBloc eventListBloc;
  EventCreateBloc({
    required this.eventListBloc,
  }) : super(EventCreateState()) {
    on<EventCreateEvent>((event, emit) {});
  }
}
════════ Exception caught by widgets library ═══════════════════════════════════
The following BindNotFoundException was thrown building DefaultPageView(dirty):
UnregisteredInstance: EventListBloc not registered.
Trace: EventCreateBloc->EventListBloc
EventCreateBloc => EventListBloc
#0      AutoInjectorImpl.get (package:auto_injector/src/auto_injector_base.dart:263:7)
#1      BindServiceImpl.getBind (package:flutter_modular/src/infra/services/bind_service_impl.dart:21:31)
#2      GetBindImpl.call (package:flutter_modular/src/domain/usecases/get_bind.dart:17:24)
#3      ModularBase.get (package:flutter_modular/src/presenter/modular_base.dart:140:22)

Teria algum motivo específico para não permitir utilizar uma bind exportada dentro do módulo owner?

Metadata

Metadata

Assignees

No one assigned

    Labels

    newNew issue request attentionquestionQuestions about using some feature or general working of the package

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions