fluttercommunity / get_it

Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
https://pub.dev/packages/get_it
MIT License
1.36k stars 148 forks source link

registerCachedFactoryParam asserts no params are passed #382

Closed franco-conroo closed 3 weeks ago

franco-conroo commented 1 month ago

The registerCachedFactoryParam function implies that params can be passed. Equivalent to registerFactoryParam. This case is not checked in the implementation of getObject in the get_it_impl file.

assert(
      !(factoryType != _ServiceFactoryType.alwaysNew &&
          (param1 != null || param2 != null)),
      'You can only pass parameters to factories!',
    );

I think the assertion should be done on a case by case bases depending on the _ServiceFactoryType.

escamoteur commented 1 month ago

agreed, this check needs the addition of cachedFactory in the assert. Could you make a PR including a test?