IoC Annotation

Quickly generate IoC singleton objects through annotations.

Installation

# pubspec.yaml
dependencies:
  ioc_annotation: ^1.0.0

dev_dependencies:
  build_runner:

Usage

  1. Use @IoC to mark classes that need to be instantiated.
// person.dart
abstract class Person {
  hello();
}

// Student.dart
import 'package:ioc_annotation/ioc_annotation.dart';
import 'package:test_demo/person.dart';

@IoC()
class Student implements Person {
  @override
  hello() {
    print('hello');
  }
}
  1. Use @IoCInstance to mark the single instance that needs to be generated.
// services.dart
import 'package:ioc_annotation/ioc_annotation.dart';

@IoCInstance()
abstract class Services {}
  1. Execute this command.
flutter pub run build_runner build
  1. Automatically generated IoC instances.
// services.ioc.dart
class Services {
  /// ....
}

LICENSE

MIT

Libraries

ioc_annotation