Skip to content
pubscout

depend

5.2.0, released 3 weeks ago by bangertstudio.kz

Dependency management and service access via InheritedWidget.

WASM-ready
$ flutter pub add depend
Source repository

What it does

Simplifies dependency management in Flutter apps by providing easy initialization and access to services and repositories across the widget tree using `InheritedWidget`. It supports both synchronous and asynchronous setup, parent dependencies, nested scopes, and lazy initialization.

AI-written summary of version 5.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to manage app services and repositories using InheritedWidget-based scopes.
  • You need lazy initialization for synchronous or asynchronous dependencies to improve startup time.
  • You want to support nested dependency scopes and parent dependencies.

Skip it when

  • You prefer annotation-based dependency injection with code generation.
  • You want a global locator pattern instead of widget-tree-scoped dependencies.

Strengths

  • Provides built-in lazy initialization via `LazyGet` and `LazyFutureGet` with support for disposal callbacks.
  • Manages container lifecycles tied to `DependencyScope` widgets.
  • Supports asynchronous initialization and custom error handling.

Weaknesses

  • Relies on widget-tree placement rather than a decoupled global container.
  • Documentation and ecosystem are smaller compared to alternative DI solutions.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0

Add depend to pubspec.yaml and wrap your app or subtree in a DependencyScope.

DependencyScope<RootContainer, RootDependencyFactory>(
  factory: RootDependencyFactory(),
  placeholder: const Center(child: CircularProgressIndicator()),
  builder: (BuildContext context) => const MyApp(),
);

Alternatives

Packages that do the same job and could replace depend.

  • lite_ref

    A lightweight, no‑dependency DI library for Dart and Flutter.

  • yx_scope_flutter

    An adapter package that provides yx_scope widgets for Flutter UI integration.

  • injector

    A simple to use and lightweight dependency injection library for Dart.

  • yx_scope

    A compile-safe dependency injection framework with advanced scoping capabilities.