kiwi_generator 4.2.1 copy "kiwi_generator: ^4.2.1" to clipboard
kiwi_generator: ^4.2.1 copied to clipboard

Generates dependency injection code using the kiwi package to reduce development time.

example/kiwi_generator_example.dart

import 'package:kiwi/kiwi.dart';

part 'kiwi_generator_example.g.dart';

abstract class Injector {
  @Register.singleton(ServiceA)
  @Register.factory(Service, from: ServiceB)
  @Register.factory(ServiceB, name: 'factoryB')
  @Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'})
  void configureWithScopedContainer(KiwiContainer scopedContainer);

  @Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'})
  void configureWithScopedContainer2([KiwiContainer scopedContainer]);

  @Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'})
  void configureWithScopedContainer3({KiwiContainer scopedContainer});

  @Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'})
  void configureWithScopedContainer4({KiwiContainer scopedContainer});

  @Register.singleton(ServiceA)
  @Register.factory(Service, from: ServiceB)
  @Register.factory(ServiceB, name: 'factoryB')
  @Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'})
  void configure();

  void methodWithoutAnnotations();

  void configureInjector() {}
}

void setup() {
  final injector = _$Injector();
  injector.configure();
}

class Service {
  const Service();
}

class ServiceA extends Service {
  const ServiceA();
}

class ServiceB extends Service {
  const ServiceB(ServiceA serviceA);
}

class ServiceC extends Service {
  const ServiceC(ServiceA serviceA, ServiceB serviceB);

  const ServiceC.other(ServiceA serviceA);
}
12
likes
140
points
27.8k
downloads

Publisher

verified publishergbtb16.com.br

Weekly Downloads

Generates dependency injection code using the kiwi package to reduce development time.

Repository (GitHub)
View/report issues

Topics

#kiwi #automatic-generator #dependency-injector

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, build_config, built_collection, code_builder, dart_style, kiwi, path, source_gen

More

Packages that depend on kiwi_generator