Immutable Dart collections using the builder pattern for safe, comparable, and hashable data structures.
Built Collection is a Dart library that provides immutable collections (List, Set, Map, Multimap) using the builder pattern. It solves the problem of safely sharing collections without defensive copying by ensuring collections are immutable, comparable, and hashable. It integrates seamlessly with Dart's core SDK collections while offering enhanced safety and performance.
Dart developers building applications that benefit from immutable data structures, such as state management in Flutter apps, functional programming paradigms, or any system requiring predictable, thread-safe data handling.
Developers choose Built Collection for its deep equality and hashing out-of-the-box, copy-on-write optimizations that avoid unnecessary copying, and its strict immutability guarantees, which reduce bugs and improve code clarity compared to mutable SDK collections.
Immutable Dart collections via the builder pattern.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Built Collections enforce immutability by not implementing mutable SDK interfaces like List or Set, preventing accidental mutations and enabling safe sharing without defensive copying.
Supports `==` for deep comparisons and caches hash codes out-of-the-box, allowing direct use in hash-based collections like HashSet, unlike core SDK collections.
Methods like `toList()` return copy-on-write wrappers, avoiding unnecessary copying when interoperating with mutable SDK collections, as highlighted in the README.
Implements only Iterable for lists and sets, not mutable interfaces, reducing misuse and enhancing code clarity in functional programming contexts.
Built Collections can contain mutable elements, but the README warns this breaks comparison and hashing, requiring careful management to avoid subtle bugs.
Every modification requires creating a builder via `toBuilder()`, making code more cumbersome compared to direct mutable operations in standard collections.
Since Built Collections don't implement mutable SDK interfaces, converting to List or Map is needed for APIs expecting those types, adding boilerplate and potential performance costs.