padi 1.0.1 copy "padi: ^1.0.1" to clipboard
padi: ^1.0.1 copied to clipboard

Async DI for flutter

Features #

This PADI - Async Dependency Injection - simple async DI

Usage #

Create new Padi scope

class UserScope extends Padi {
  @override
  Future<void> initAsync(BuildContext context) async {}
}

Add some deps

class UserScope extends Padi {
  late final String yourDep;
  @override
  Future<void> initAsync(BuildContext context) async {
    yourDep = "hello di";
  }

  @override
  Future<void> onError(BuildContext context, Object? error, StackTrace? stackTrace) async {
    //your hanlde here
    super.onError(context, error, stackTrace);
  }
}

Create Padi Widget that will wrap your dependency

runApp(
 PadiWidget<UserScope>(
        create: UserScope.new,
        loaderBuilder: (context) => Container(),
        errorBuilder: (context) => Container(),
        child: const App(),
      ),
)

get dependency from your di

PadiScope.of<UserScope>(context);
3
likes
140
points
23
downloads

Publisher

verified publishergdtuka.ru

Weekly Downloads

Async DI for flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on padi