ezy_di 0.0.2 copy "ezy_di: ^0.0.2" to clipboard
ezy_di: ^0.0.2 copied to clipboard

discontinued
outdated

Dependency Injection Tools for Dart

Dependency Injection #

class Animal {
  final Dog dog;
  final Fish fish;
  final Bird bird;
  final Duck duck;

  const Animal(this.dog, this.fish, this.bird, this.duck);
}

class Bird {
  final Fly fly;
  Bird(this.fly);
}

class Dog {
  final Walk walk;
  Dog(this.walk);
}

class Duck {
  final Swim swim;
  final Walk walk;
  final Fly? fly;
  Duck(this.swim, {required this.walk, this.fly});
}

class Fish {
  final Swim swim;
  Fish(this.swim);
}

class Fly {
  start() {
    return "flying";
  }
}

class Swim {
  start() {
    return "swimming";
  }
}

@Singleton()
class Walk {

  const Walk() {
    print('this class will create only once and share with other classes').
  }

  start() {
    return "walking";
  }
}

void main() {
    final injector = Injector();
    Animal animal = injector.get<Animal>();
    animal.bird.fly.start() // flying
    animal.fish.swim.start() // swimming
}

Support Singleton provider #

@Singleton()
class Walk {

  const Walk() {
    print('this class will create only once and share with other classes').
  }

  start() {
    return "walking";
  }
}

Support both positional and named params #

class Duck {
  final Swim swim;
  final Walk walk;
  final Fly? fly;
  Duck(this.swim, {required this.walk, this.fly});
}

0
likes
0
points
12
downloads

Publisher

verified publisherzinkyawkyaw.dev

Weekly Downloads

Dependency Injection Tools for Dart

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on ezy_di