talira

tuple (Dart)

A tuple data structure for Dart

open sourceBSD-2-Clausefree

tuple is a Dart package from Google that provides immutable tuple types (Tuple2 up to Tuple7) for bundling several values into one object, with helpers such as withItem1 that return a changed copy. Its maintainers consider it feature complete: since Dart 3, records cover the same uses, so they suggest records for new code and keep the package for bug fixes only. It's BSD-2-Clause licensed and published on pub.dev as tuple.

Problems it solves

  • return two values from a function in older Dart code
  • keep using Tuple2 in a Dart project that predates records
  • bundle a pair of values into one immutable object in Dart

Features

  • immutable tuple types
  • copy-with helpers for each item

Limitations

  • Feature complete and only receives bug fixes: its maintainers suggest Dart 3 records for new code1