dartin 0.1.0 copy "dartin: ^0.1.0" to clipboard
dartin: ^0.1.0 copied to clipboard

outdated

A pragmatic lightweight dependency injection framework for Flutter developers.

example/lib/main.dart

import 'package:dartin/dartin.dart';

import 'dummy.dart';

//constant scope
const other = DartInScope('other');
const params = DartInScope('params');

final dummy1 = Dummy(1);
final dummy2 = Dummy(2);

//define module
final m = Module([
  single<Dummy>(dummy1),
])
  ..withScope(other, [
    single<Dummy>(dummy2),
  ])
  ..withScope(params, [
    factory<Dummy>(({params}) => Dummy(params.get(0))),
  ]);

main() {

  startDartIn([m]);

  //default
  final value1 = inject<Dummy>();
  //scope
  final value2 = inject<Dummy>(scope: other);
  //parameters
  final value3 = inject<Dummy>(scope: params, params: [3]);

}
8
likes
0
pub points
70%
popularity

Publisher

unverified uploader

A pragmatic lightweight dependency injection framework for Flutter developers.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on dartin