koin 0.14.2 copy "koin: ^0.14.2" to clipboard
koin: ^0.14.2 copied to clipboard

A pragmatic lightweight dependency injection framework for Dart projects.

example/example.dart

import 'package:koin/koin.dart';

class Post {
  final String title;
  final String body;

  Post(this.title, this.body);
}

abstract class PostRepository {
  List<Post> getAll();
}

class RestPostRepository implements PostRepository {
  @override
  List<Post> getAll() {
    return [Post("Title", "BOdy"), Post("Title", "BOdy")];
  }
}

var postModule = Module()..single<PostRepository>((s) => RestPostRepository());

void main() {
  var koin = startKoin((app) {
    app..module(postModule);
  }).koin;

  var postRepository = koin.get<PostRepository>();

  print(postRepository.getAll());
}
59
likes
40
pub points
42%
popularity

Publisher

unverified uploader

A pragmatic lightweight dependency injection framework for Dart projects.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

kt_dart, meta

More

Packages that depend on koin