Skip to content
pubscout

tuple

2.0.2, released 3 years ago by google.dev

Provides immutable tuple classes for grouping values.

WASM-ready
$ flutter pub add tuple
Source repository

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.

Works with

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