dm_gen 0.5.1+1 copy "dm_gen: ^0.5.1+1" to clipboard
dm_gen: ^0.5.1+1 copied to clipboard

dependency manager.

dm_gen #

Dependency manager like dagger from android. This package can also create an instance of a class from a reference to the constructor and dependency area

Example #

Code from example/

Create abstract class with annotation @Modules({{you module list}}) for dependency call

    @Modules([CacheModule, DbModule, NetworkModule])
    abstract class Dm {

      static Future<Dm> init() {
        return DmImpl().init();
      }

      @provide
      DB db();

      CommonConsumer commonConsumer ();

      MarkInjectConsumer markInjectConsumer();

      WithParameterConsumer withParameterConsumer(String name);
    }

The @Modules annotation contains classes with @provide methods tagged that will be available for calling in other modules and consumers.

    class CacheModule {
      @provide
      @singleton
      Cache cacheModule(DB db, Network<String> network) => Cache(db, network);
    }

This function may contain parameters with types that will be taken from other modules

Dependency can get from module or can creating from first or marked @inject constructor in returned class like this

    class MarkInjectConsumer {
      DB db;
      Cache cache;

      MarkInjectConsumer();

      @inject
      MarkInjectConsumer.cached(this.db, this.cache);
    }
2
likes
80
pub points
0%
popularity

Publisher

unverified uploader

dependency manager.

Repository (GitLab)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

analyzer, build, dm, source_gen

More

Packages that depend on dm_gen