familyPod<T extends Pod, Arg> function
T Function(Arg arg)
familyPod<T extends Pod, Arg>(
- T create(
- Arg arg
Create a family factory function, for indexing similar pods with the
Arg
type.
final userPod =
familyPod((int id) => pod((ref) => ref.watch(listOfUsers).getById(id)));
// To get a pod that points to user with id 123
final user = container.get(userPod(123));
Implementation
T Function(Arg arg) familyPod<T extends Pod<dynamic>, Arg>(
T Function(Arg arg) create,
) {
final pods = HashMap<Arg, T>();
return (arg) => pods[arg] ??= create(arg);
}