Skip to content
pubscout

functional_data

1.2.0, released 3 years ago by spkersten.nl

Annotations and helper lenses for generating boilerplate for immutable data types.

WASM-ready
$ flutter pub add functional_data
Source repository

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.

Works with

Packages commonly used together with functional_data: ones it builds on, ones built on it, and its own family.