functional_data
1.2.0, released 3 years ago by spkersten.nl
Annotations and helper lenses for generating boilerplate for immutable data types.
What it does
Generates mixins providing operator==, hashCode, copyWith, toString, and lenses for data classes via build_runner. Lenses allow viewing and modifying nested data structures immutably.
AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want immutable data classes with equality, copying, and string representations without writing boilerplate.
- You need to deeply update nested data structures using lenses.
Skip it when
- You prefer writing data classes and copy methods by hand.
- You want an alternative code generator like Freezed that handles unions and pattern matching.
Strengths
- Minimally intrusive on class design by using mixins.
- Powerful lens support for manipulating nested objects and collections.
Weaknesses
- Requires running build_runner for code generation.
- Limited feature set compared to broader generators like Freezed.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 2
Add build_runner and functional_data_generator to dev_dependencies and run build_runner.
@FunctionalData()
class Person extends _$Person {
final String name;
final int age;
const Person({this.name, this.age});
}Alternatives
Packages that do the same job and could replace functional_data.
- json_annotation
Provides annotations for json_serializable to generate JSON (de)serialization code.
84Compare - auto_mappr_annotation
Annotations for the auto_mappr code-generator to map between objects.
79Compare - build
Package for authoring build_runner compatible code generators.
87Compare - freezed_annotation
Annotations for the freezed code-generator.
78Compare
Works with
Packages commonly used together with functional_data: ones it builds on, ones built on it, and its own family.