You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
It is a good idea to have this registerFactoryParam. It was a missing part of get_it to become a complete DI tools for Flutter. There is still some improvement that we can do here. Right now get_it doesn't support constructor injection very well and you have to use property injection (constructor injection in some cases like testing is a better practice than property injection).
The registerFactoryParam can be a good solution for solving this problem but it's input parameters now has limits. This limit can cause problem in cases like this.
Here is a sample code works perfectly, but if your input parameters can't be more than 2 which limits this.
classA {}
classB {}
classC {
A a;
B b;
int num1;
int num2;
C(this.a, this.b, this.num1, this.num2);
}
main() {
GetIt.I.registerFactory<A>(() =>A());
GetIt.I.registerFactory<B>(() =>B());
GetIt.I.registerFactoryParam<C, int, int>(
(param1, param2) =>C(GetIt.I<A>(), GetIt.I<B>(), param1, param2));
C c =GetIt.I.get<C>(param1:1, param2:2);
}
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Hi
It is a good idea to have this
registerFactoryParam
. It was a missing part of get_it to become a complete DI tools for Flutter. There is still some improvement that we can do here. Right now get_it doesn't support constructor injection very well and you have to use property injection (constructor injection in some cases like testing is a better practice than property injection).The
registerFactoryParam
can be a good solution for solving this problem but it's input parameters now has limits. This limit can cause problem in cases like this.Here is a sample code works perfectly, but if your input parameters can't be more than 2 which limits this.
The text was updated successfully, but these errors were encountered: