Pub GitHub Stars License: MIT Linter

Flutter integration for arbor – a modular and compile-time safe DI for Flutter without fragility and magic.



Read more about arbor before using this package. This package is a Flutter integration for arbor and should be used in pair.

flutter_arbor provides a widget that effectively propagates dependency nodes using InheritedWidgets to the Element tree.


As arbor is a pure Dart package, it can be used in any Dart project.

However, it is not a Flutter package and does not provide any Flutter-specific features – this is where flutter_arbor comes in, providing a way to effectively propagate dependency nodes using InheritedWidgets to the Element tree, integrating the package with Flutter.


Add flutter_arbor to your pubspec.yaml file:

  flutter_arbor: "current version"

Or do it via CLI:

$ flutter pub add flutter_arbor


flutter_arbor can be used in two ways: to provide an initial root Tree instance or to provide a Tree instance for a stateful subtree, that is, a ChildNode created through a child method.

An example dependencies structure can be described as follows:

class AppDependencies extends BaseTree<AppDependencies> {
  ObjectFactory<ExampleChild> get exampleChild => child(ExampleChild.new);

class ExampleChild extends BaseChildNode<ExampleChild, AppDependencies> {

This structure consists of two nodes: AppDependencies and ExampleChild. AppDependencies is a root node, and ExampleChild is a child node of AppDependencies.

Root node

To provide a root Tree instance, a default unnamed constructor of NodeScope should be used:

  create: (context) => AppDependencies(),
  child: child,

Placing this widget in the Widgets structure will effectively propagate AppDependencies to all the Elements below it, which can be accessed through NodeScope.of<N>(context, listen: listen).

Child node

To provide a Tree instance for a stateful subtree, a named constructor child of NodeScope should be used:

  create: (context, find) => find<AppDependencies>().exampleChild,
  child: child,

The named constructor offers a shortcut to finding a parent node and creating a child node from it and lifts the return type of create to a thunk - ObjectFactory<N>/N Function().