composable_architecture 0.2.0
composable_architecture: ^0.2.0 copied to clipboard
Port of The Composable Architecture for Dart. A state management library with composability and exaustive testability at it's core.
🎙️⚠️
I would love community insights and help for taking next steps.
If you feel like contributing, join discussions here!
The Composable Architecture - Dart (experimental) #
Port of The Composable Architecture (TCA, for short) for the Dart Language and Flutter Framework.
Examples #
https://github.com/user-attachments/assets/27af38b1-189b-4f59-8710-f41026ca20fa
This repo comes with lots of examples to demonstrate how to solve common and complex problems with the Composable Architecture. Check out this directory to see them all, including:
Setup #
This package relies on code generation to enhance the developer experience and improve coding ergonomics. It includes built-in generators that create KeyPaths for states and actions in types annotated with @KeyPathable and @CaseKeyPathable.
Types annotated with @KeyPathable automatically get copyWith, equality (==), hashCode, and toString methods generated for you. You do not need to provide your own copyWith or equality implementations—these are handled by the code generator.
If you want additional features (like unions, pattern matching, or deep immutability), you can still use @freezed or another code generator alongside @KeyPathable. In that case, follow the documentation for that tool as well.
To enable the generators, you must explicitly add them as dependencies in your pubspec.yaml:
dependencies:
composable_architecture: ...
Additionally, to run the generators, you need to include build_runner as a development dependency:
dev_dependencies:
build_runner: ...
If you are using Flutter, you need to explicitly depend on both composable_architecture and composable_architecture_flutter. This is the case because even though composable_architecture_flutter depends on composable_architecture, build_runner needs the direct dependency on composable_architecture to get access to the generators.
dependencies:
composable_architecture: ...
composable_architecture_flutter: ...
Finally, for the generators to work, you must add part directives in the file containing the type annotations, in addition to importing composable_architecture:
import 'package:composable_architecture/composable_architecture.dart';
part 'your_file_name.g.dart';
@KeyPathable()
final class YourState with _$YourState {}