Skip to content

Using singletone inside other singletone leads to error #54

Closed
@andzejsw

Description

@andzejsw

I have 2 singletones. First is for user preferences and second is for connection with server.
Inside WampService (connection singletone) i am implementing InternalSettings (preferences singletone) like this:
InternalSettings mInternalSettings = locator<InternalSettings>();

My setup locator looks like this:

void setupLocator() async {
  var iSettingsInstance = await InternalSettings.getInstance();
  var iWampInstance = await WampService.getInstance();
  locator.registerSingleton<InternalSettings>(iSettingsInstance);
  locator.registerSingleton<WampService>(iWampInstance);
}

Is there some way to implement singletones, which ones also depends from other singletones?
Error message is inside WampService file, where i am using locator: InternalSettings is not registered inside GetIt.

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