Package selection guidance compiled from public package information, community data, and project usage.
FunctionalData is a Dart package that provides annotations and utility helpers for creating lenses—functional programming constructs used to access and modify nested data structures. It works in conjunction with the `function_data_generator` code generator to automatically produce boilerplate-free, immutable data classes with powerful update capabilities. The package enables safe, composable updates to deeply nested objects without mutation, promoting functional programming principles in Flutter and Dart applications. Ideal for state management and data transformation workflows.
Use cases
Immutable state updates
Nested data manipulation
State management in Flutter apps
Functional programming patterns
Code generation for data classes
Key features
Automatic lens generation
Immutability support
Deep nested updates
Type-safe transformations
Integration with code generators
Suitable for
Developers using functional programming
Flutter apps with complex state
Teams prioritizing immutability
Code generation workflows
Data-heavy applications
Considerations
Requires `function_data_generator`
Learning curve for lenses
Limited runtime reflection
Not suitable for simple data models
Additional build step needed
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Functional Data
Simple and non-intrusive code generator for boilerplate of data types. The package generates a simple mixin with
operator==, hashCode, copyWith, toString, as well as lenses.
Boiler plate
Because the boiler plate is generated as a mixin, it is minimally intrusive on the interface of the class. You
only have to provide a constructor with named arguments for all fields and extend the generated mixin.
Because of this design, you have complete control over the class. You can, for example, add named constructors
or methods to the class like you're used to.
Lenses
For every class, lenses are generated for all fields which allow viewing a field or creating a new
instance of the classes with that field modified in some way. For example, the lens of Person's name is
Person$.name. To focus a lens on a specific instance use its of method:
This isn't very exciting yet. The power of lenses comes to light when you combine them. It allows you to easily
create a copy of a large nested data structure with one of the fields in a leaf modified. Two lenses can be chained
using then.
To specify which features should be generated for you whole project, create a file called functional_data_options.yaml
in the root of your project.
Class specific arguments will override the project level configuration.