dartin 0.1.5

Flutter Android iOS web

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]);

}
6
likes
100
pub points
79%
popularity

A pragmatic lightweight dependency injection framework for Flutter developers.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

scuyttyuuy@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on dartin