zef_di_inglue 0.0.1 copy "zef_di_inglue: ^0.0.1" to clipboard
zef_di_inglue: ^0.0.1 copied to clipboard

discontinuedreplaced by: zef_di_core

An adapter for the ZEF_DI_Abstractions package.

example/zef_di_inglue_example.dart

import 'package:zef_di_abstractions/zef_di_abstractions.dart';
import 'package:zef_di_inglue/zef_di_inglue.dart';

import 'test_classes/implementations/index.dart';
import 'test_classes/interfaces/index.dart';

void main() {
  // Build the ServiceLocator
  ServiceLocatorBuilder().withAdapter(InglueServiceLocatorAdapter()).build();

  // Register the Singleton
  ServiceLocator.I.registerInstance(
    Dolphin(),
    interfaces: [Animal, Fish],
  );

  ServiceLocator.I.registerInstance(
    Dolphin(),
    interfaces: [Animal, Fish],
  );

  // Retrieve the Singleton
  final instance = ServiceLocator.I.getFirst<Dolphin>();

  // Retrieve the instance via the interface
  final interfaceInstance = ServiceLocator.I.getFirst<Animal>();

  // Do something with the instances
  print(instance.runtimeType); // Output: Dolphin
  print(interfaceInstance.runtimeType); // Output: Dolphin
}
2
likes
130
points
69
downloads

Publisher

verified publisherzooper.dev

Weekly Downloads

An adapter for the ZEF_DI_Abstractions package.

Homepage
Repository (GitHub)
View/report issues

Topics

#dependency-injection #di #injection #ioc #inversion-of-control

Documentation

API reference

Funding

Consider supporting this project:

buymeacoffee.com

License

MIT (license)

Dependencies

any_of, zef_di_abstractions

More

Packages that depend on zef_di_inglue