collection
1.19.1, released 2 years ago by dart.dev
Utility functions and classes that extend Dart's collection types and algorithms.
What it does
Provides additional utilities, wrappers, algorithms, equality comparers, and priority queues for working with collections in the style of dart:collection. It includes helpers for zipping iterables, sorting, binary search, and specialized collection types.
AI-written summary of version 1.19.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need advanced equality comparisons for maps, sets, and lists.
- You want priority queues or space-efficient boolean lists.
- You need convenient extension methods on iterables and lists like sorting, min, max, and slicing.
Skip it when
- You only require standard Dart core collections and basic operations.
- You need reactive state management collections that automatically trigger UI rebuilds.
Strengths
- Comprehensive collection algorithms and equality utilities.
- Extensive extension methods on standard iterables and lists.
- Lightweight with no external dependencies.
Weaknesses
- Does not provide reactive state management or automatic UI updates.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Simply add the package to your pubspec.yaml dependencies.
import 'package:collection/collection.dart';
void main() {
final equality = const MapEquality(IdentityEquality(), ListEquality());
print(equality.equals({'a': [1, 2]}, {'a': [1, 2]}));
}Alternatives
Packages that do the same job and could replace collection.
- weak_map
A map whose keys are weakly held, and cache functions for memoization.
80Compare - stream_transform
Extension methods adding common stream transform operators
91Compare - gtk
GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.
76Compare - ordered_set
Ordered Set that keeps elements sorted and allows duplicates by priority.
82Compare
Works with
Packages commonly used together with collection: ones it builds on, ones built on it, and its own family.
- analyzerBuilt on collectionPerforms static analysis of Dart code for tool integration and embedding.
- yamlBuilt on collectionA Dart library for parsing YAML documents into Dart data structures.
- pub_semverBuilt on collectionVersions and version constraints implementing pub's versioning policy.
- xmlBuilt on collectionFull-featured XML and XPath library for DOM parsing, SAX streaming, and fluent building.
- globBuilt on collectionA file and directory globbing library that supports Bash-style path matching and listing.
- petitparserBuilt on collectionBuild fast, composable, and type-safe grammars and parsers in plain Dart code.
- built_valueBuilt on collectionImmutable value types with builders, enum classes and JSON serialization for Dart.
- dart_styleBuilt on collectionProvides an API and CLI to format Dart source code automatically.