Signals is a new core primitive reactivity library and not a framework which means it can be used with any dependency injection solution or none at all.
This library aims to adapt to any application architecture and you decide how you want to manage your signals.
This guide will show you how to use Signals with popular DI solutions.
Provider
Provider is a simple way to provide objects to your widgets.
Note: Consumer can also be used instead of Watch.
GetIt
GetIt is a simple service locator that can be used in any Dart or Flutter project.
Riverpod
Riverpod is a data-binding and reactive caching framework for Flutter and Dart.
InheritedWidget
InheritedWidget is a simple built in way to provide objects to your widgets. This comes at the cost of storing a single signal per type.
Note: This is a new feature added in version 5.0.0 and is still experimental.
If you want to define multiple signals with the same type, then you will need to create custom classes for the container.
Lite Ref
Lite Ref is a simple way to provide disposable objects to your widgets.
You can use any class that implements Disposable and it will be disposed when the widget is removed from the widget tree. You also don’t need to provide a dispose function for the ScopedRef.
Zones
Zones are another built in way to provide objects to your application via Dart Zones.
Scoped Deps is a package that easily integrates Zones with Dart.
Global Signals
Global signals are a simple way to provide objects to your widgets.
This requires you to manage the lifecycle of the signal and dispose it when no longer needed.
Note: This is not recommended for large applications and useful for select use cases like logging, analytics, auth, etc.