tuple
2.0.2, released 3 years ago by google.dev
Provides immutable tuple classes for grouping values.
What it does
The package defines Tuple1 through Tuple7 classes that hold a fixed number of items. Instances are immutable, hashable, and can be used as map keys.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need to group a small fixed number of heterogeneous values
- Legacy code depends on Tuple classes
- Require stable hash codes for tuples in collections
Skip it when
- Prefer Dart 3.0 records for new code
- Tuples larger than seven items
- Performance-critical code where a lightweight struct is needed
Strengths
- Type-safe grouping of values
- Immutability and hashability
- No external dependencies
Weaknesses
- Feature complete but not actively enhanced
- Limited to seven items
- Superseded by Dart records in newer versions
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
const t = Tuple2<String, int>('a', 10);
print(t.item1); // prints 'a'
print(t.item2); // prints '10'Alternatives
Packages that do the same job and could replace tuple.
- fast_immutable_collections
Fast immutable lists, sets, maps, and multimaps for Dart
91Compare - more
A collection of utility extensions and specialized data structures for Dart.
90Compare - ordered_set
Ordered Set that keeps elements sorted and allows duplicates by priority.
82Compare - weak_map
A map whose keys are weakly held, and cache functions for memoization.
80Compare
Works with
Packages commonly used together with tuple: ones it builds on, ones built on it, and its own family.
- flutter_math_forkBuilt on tupleFast and high-quality TeX math equation rendering with pure Dart and Flutter.
- crclibBuilt on tupleProvides CRC calculators as Dart converters and stream transformers.
- signalr_netcoreBuilt on tupleFlutter client for ASP.NET Core SignalR supporting WebSocket, SSE, LongPolling and MessagePack.
- text_searchBuilt on tupleAn in-memory fuzzy text searching library for Dart.
- growthbook_sdk_flutterBuilt on tupleFeature flagging and A/B testing platform client for Flutter apps.
- flutter_code_editorBuilt on tupleA customizable code field widget supporting syntax highlighting and code folding.
- mysql_client_plusBuilt on tupleNative MySQL client written in Dart with connection pooling, transactions, and TLS support.
- mysql_clientBuilt on tupleNative MySQL and MariaDB client written in Dart.