bind<T> abstract method

void bind<T>(
  1. dynamic factory(
    1. ContainerInterface
    ), {
  2. bool singleton,
})

Registers a factory function for type T.

The factory is called each time T is resolved, unless singleton is true. If singleton is true, the instance is created once and reused.

  • factory: A function that takes the container and returns an instance of T.
  • singleton: If true, the factory is treated as a singleton.

Throws an exception if a binding for T already exists.

Implementation

void bind<T>(dynamic Function(ContainerInterface) factory, {bool singleton});