Skip to content
pubscout

built_collection

6.0.0, released 4 weeks ago by dart.dev

Immutable collections based on SDK collections with builder pattern.

Flutter FavoriteWASM-ready
$ flutter pub add built_collection
Source repository

What it does

Provides immutable collection classes (like BuiltList, BuiltMap, BuiltSet) and corresponding mutable builder classes. Uses copy-on-write to avoid unnecessary copying and supports deep comparison and hashing.

AI-written summary of version 6.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need safe, immutable collections to share across your app without defensive copying.
  • You want deep comparison and hashing support for collections.
  • You use built_value and need matching immutable collections.

Skip it when

  • You need direct mutability on standard SDK collection interfaces (built collections do not implement standard List/Set interfaces).
  • You want a fully codegen-free state model where native collections or other packages suffice.

Strengths

  • Enforces immutability and prevents accidental state mutations.
  • Provides deep equality and caching for efficient comparisons and hashing.
  • Uses copy-on-write wrappers to avoid unnecessary data copying.

Weaknesses

  • Collections do not implement core SDK mutable interfaces (e.g., BuiltList does not implement List).
  • Requires converting to/from builders or views when interoperating with standard SDK code.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
BuiltList([1, 2, 3]) == BuiltList([1, 2, 3]);

Alternatives

Packages that do the same job and could replace built_collection.

Works with

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