fabric_generator 0.0.7 copy "fabric_generator: ^0.0.7" to clipboard
fabric_generator: ^0.0.7 copied to clipboard

Generator for Fabric

Fabric #

Fabric is a dependency injection library. Using a generator, it can automate the task of wiring dependencies for you.

Features #

  • A central registry for registering dependencies
  • A generator to automatically generate wiring code

Getting started #

Add the Fabric libraries to pubspec.yaml:

dependencies:
  fabric_metadata: 0.0.1
  fabric_manager: 0.0.1

dev_dependencies:
  build_runner: ^2.1.10
  fabric_generator: 0.0.1
copied to clipboard

Usage #

Add the @managed annotation to the classes you want to manage dependencies for:

@managed
class FooService {
  final FooRepository repository;
  
  FooService(this.repository);
}

@managed
class PostgresqlFooRepository implements FooRepository {
  
}
copied to clipboard

Generate wiring code:

dart pub get
dart run build_runner build 
copied to clipboard

Import the generated code and get the stuff you need:

import 'fabric.g.dart';

main() {
  var fabric = createFabric();
  var service = fabric.getInstance<FooService>();
}
copied to clipboard
0
likes
80
points
122
downloads

Publisher

unverified uploader

Weekly Downloads

2024.07.06 - 2025.01.18

Generator for Fabric

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, fabric_manager, fabric_metadata, merging_builder_svb, source_gen

More

Packages that depend on fabric_generator