Skip to content

registerFactoryParam does not allow List<whatever> params #67

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
spiritinlife opened this issue Apr 15, 2020 · 5 comments
Closed

registerFactoryParam does not allow List<whatever> params #67

spiritinlife opened this issue Apr 15, 2020 · 5 comments

Comments

@spiritinlife
Copy link

It seems that providing a List of a class does not work with registerFactoryParam.
There error shown is

Incompatible Type passed as param1
expected: List<FilterBucket> actual: List<FilterBucket>
'package:get_it/get_it_impl.dart':
Failed assertion: line 108 pos 17: 'param1 == null || param1.runtimeType == param1Type'
4:36

version: 4.0.1

@thanhnamitit
Copy link

I got the same error, seems this one is not work with built_value too

@votruk
Copy link

votruk commented Apr 22, 2020

Yeah, I've tried this new feature too and can confirm that you cannot pass BuiltValue classes as params.

But everything works fine if you replace the following lines in get_it_impl.dart

            assert(
                param1 == null || param1.runtimeType == param1Type,
                'Incompatible Type passed as param1\n'
                'expected: $param1Type actual: ${param1.runtimeType}');
            assert(
                param2 == null || param2.runtimeType == param2Type,
                'Incompatible Type passed as param2\n'
                'expected: $param2Type actual: ${param2.runtimeType}');

with

            assert(
                param1 == null || param1 is P1,
                'Incompatible Type passed as param1\n'
                'expected: $param1Type actual: ${param1.runtimeType}');
            assert(
                param2 == null || param2 is P2,
                'Incompatible Type passed as param2\n'
                'expected: $param2Type actual: ${param2.runtimeType}');

@escamoteur
Copy link
Collaborator

@votruk but this isn't what should be checked.

This should check if the passed parameter has the same type as the one the factory was registered with.

@escamoteur
Copy link
Collaborator

so I think I will drop this test

@escamoteur
Copy link
Collaborator

Should work with the next version

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

No branches or pull requests

4 participants