Skip to content

Changed equal to not equal in factory param type check #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ResoDev
Copy link

@ResoDev ResoDev commented Mar 20, 2020

Fixed factory parameter type check. Otherwise, factory params wouldn't work and you'd get assertion errors such as expected: String actual: String.

@escamoteur
Copy link
Collaborator

@ResoDev Your change dose solve the assert but in fact disables the type checking as a whole. It's strange that you get an error there because I have tests that work correctly. Maybe an isinsetad of an == would be better.

@escamoteur
Copy link
Collaborator

Just tested this here again:

  test('register factory with one Param', () {
    var getIt = GetIt.instance;
    getIt.reset();

    constructorCounter = 0;
    getIt.registerFactoryParam<TestClassParam, String, void>(
        (s, _) => TestClassParam(param1: s));

    //var instance1 = getIt.get<TestBaseClass>();

    var instance1 = getIt<TestClassParam>(param1: 'abc');
    var instance2 = getIt<TestClassParam>(param1: '123');

    expect(instance1 is TestClassParam, true);
    expect(instance1.param1, 'abc');
    expect(instance2 is TestClassParam, true);
    expect(instance2.param1, '123');
  });

and it works

@escamoteur
Copy link
Collaborator

I removed the check completely because Dart does nor support the needed check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants