registerFactoryParamAsync<T extends Object, P1, P2> abstract method

void registerFactoryParamAsync<T extends Object, P1, P2>(
  1. FactoryFuncParamAsync<T, P1?, P2?> factoryFunc, {
  2. String? instanceName,
})

registers a type so that a new instance will be created on each call of getAsync on that type based on up to two parameters provided to getAsync() the creation function is executed asynchronously and has to be accessed with getAsync T type to register P1 type of param1 P2 type of param2 if you use only one parameter pass void here factoryFunc factory function for this type that accepts two parameters instanceName if you provide a value here your factory gets registered with that name instead of a type. This should only be necessary if you need to register more than one instance of one type.

example: getIt.registerFactoryParam<TestClassParam,String,int>((s,i) async => TestClassParam(param1:s, param2: i));

if you only use one parameter:

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

Implementation

void registerFactoryParamAsync<T extends Object, P1, P2>(
  FactoryFuncParamAsync<T, P1?, P2?> factoryFunc, {
  String? instanceName,
});