composable_architecture 0.1.0 copy "composable_architecture: ^0.1.0" to clipboard
composable_architecture: ^0.1.0 copied to clipboard

Port of The Composable Architecture for Dart. A state management library with composability and exaustive testability at it's core.

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.

However, the generated code has some basic requirements: types conforming to @KeyPathable must implement a copyWith method. Users can provide this method however they prefer, but the recommended approach is to use a generator—specifically, @freezed.

To enable these additional generators, you must explicitly add them as dependencies in your pubspec.yaml:

dependencies:
  composable_architecture: ...
  freezed: ...

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: ...
  freezed: ...

The freezed_annotation package is already included and exported by composable_architecture, so you don’t need to add it manually.

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.freezed.dart';
part 'your_file_name.g.dart';

@freezed
@KeyPathable()
final class YourState with _$YourState {}

You can replace freezed with any other generator that provides a copyWith method, or even add the method yourself. In each case, update the part directives according to the documentation of the chosen tool.

2
likes
150
points
111
downloads

Publisher

unverified uploader

Weekly Downloads

Port of The Composable Architecture for Dart. A state management library with composability and exaustive testability at it's core.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, freezed_annotation, source_gen

More

Packages that depend on composable_architecture