Skip to content

Bug when trying to declare nested dependencies #9

Description

@R9n

Hi.
I'm having trouble to do nested dependencies injection. I have a AppModule like this:


class Dependencies extends Module {
  Dependencies() {
    single(DioDart());
    single(JobsController(get()));  <===== here's the problem, the lib cant find DiotDart instance, but it has already declared above

    single(JobsService(get()));
    single(JobTypesServices());
    single(AuthServices());
    single(ServiceProvidersService(get()));
    single(UsersService());
  }
}

JobsController snippet:

  static String endpoint = '${apiURL}/jobs';
  DioDart dioDart;
  JobsController(this.dioDart);

Console error Stack (Debug mode):

[Easy Localization] Load asset from assets/i18n
I/flutter (21971): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21971): │ #0   new InjectorIO.start (package:injectorio/src/io.dart:44:14)
I/flutter (21971): │ #1   MyApp.build (package:bridi_mobile/main.dart:47:16)
I/flutter (21971): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (21971): │ 🐛 Initiated InjectorIO in mode: InjectorMode.DEBUG
I/flutter (21971): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21971): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21971): │ #0   DefinitionRegistry._log (package:injectorio/src/bean_registry.dart:83:44)
I/flutter (21971): │ #1   DefinitionRegistry._showInstanceNotFound (package:injectorio/src/bean_registry.dart:91:7)
I/flutter (21971): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (21971): │ 🐛 InjectorIO:::	!!!--- Instance of type DioDart not found ---!!!
I/flutter (21971): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[Easy Localization] Build
[Easy Localization] Init Localization Delegate
[Easy Localization] Init provider

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following _Exception was thrown building MyApp(dirty, dependencies: [_InheritedProviderScope<ThemeController>]):
Exception: Instance of DioDart not found. Make sure you added
        it by using module or with [single()], [factory()] definition.

The relevant error-causing widget was: 
  MyApp file:///home/ark/Haizen/projetox/bakcup/bridi-mobile/lib/main.dart:34:18
When the exception was thrown, this was the stack: 
#0      DefinitionRegistry.get (package:injectorio/src/bean_registry.dart:60:7)
#1      get (package:injectorio/src/component_binder.dart:22:24)
#2      get (package:injectorio/injectorio.dart:9:15)
#3      new Dependencies (package:bridi_mobile/main.dependencies.dart:14:27)
#4      MyApp.build (package:bridi_mobile/main.dart:47:31)
...
════════════════════════════════════════════════════════════════════════════════════════════════════

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions