diverpro 1.0.4
diverpro: ^1.0.4 copied to clipboard
DiverPro is a State Management Library and Dependency Injection package for Flutter. It's my take on Riverpod and Provider.
import 'dart:math';
import 'package:diverpro/abs/di_container.dart';
void main() {
// DiContainer.register<Example>(DiverproExample());
// DiContainer.registerFactory<Example>(() => DiverproExample());
// DiContainer.registerSingleton<Example>(() => DiverproExample());
DiContainer.registerLazySingleton<Example>(() => DiverproExample());
(DiContainer.get<Example>())?.run();
Future.delayed(Duration(seconds: 1), () =>
(DiContainer.get<Example>())?.run()
);
}
abstract class Example {
void run();
}
class DiverproExample implements Example {
late final int randIndex = Random().nextInt(30);
@override
void run() {
print('awesome $randIndex');
}
}
copied to clipboard