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

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>(({params}) =>  dummy1 ),
])
  ..withScope(other, [
    single<Dummy>(({params}) =>  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
40
pub points
68%
popularity

Publisher

unverified uploader

A pragmatic lightweight dependency injection framework for Flutter developers.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on dartin