パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.2

tuple

タプルデータ構造を提供するライブラリ。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
150万
いいね数
484
Pub ポイント
140

パッケージをインストール

flutter pub add tuple

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

タプルパッケージは、Dart向けに軽量で型安全なタプルデータ構造を提供し、異なる型の複数の値を単一の不変オブジェクトにグループ化できるようにします。最大7つの要素をサポートし、作成、アクセス、分解に対して直感的な構文を提供します。シンプルさとパフォーマンスを重視して設計されており、カスタムクラスを定義せずに複数の関連する値を返すまたは渡す際のコードの明確性を高めます。このライブラリは、関数型プログラミングパターンや簡潔なデータ集約が必要なシナリオにおいて特に有用です。

用途

  • 関数から複数の値を返す
  • メソッド間でグループ化されたデータを渡す
  • 関数型プログラミングパターン
  • 状態管理におけるデータ転送の簡素化
  • 小さなデータ構造のボイラープレートを回避する

主な機能

  • 変更不可能なタプルオブジェクト
  • 要素間の型安全
  • 最大 7 要素まで対応
  • パターンマッチングによるデストラクチャリング
  • 最小の実行時オーバーヘッド
  • 作成およびアクセスのクリーンな構文

適している対象

  • 軽量なデータコンテナを求める開発者
  • 関数型プログラミングスタイルを使用するプロジェクト
  • 効率的な複数値の返却を必要とするアプリ
  • 簡単なデータ用にカスタムクラスの定義を避ける
  • すべての主要プラットフォームをターゲットとしたクロスプラットフォームアプリ

注意事項

  • 7つの要素に制限されています
  • 大規模または複雑なデータモデルには適していません
  • 不変性は、変更可能な使用ケースのために回避策を必要とする可能性があります
  • 新しい開発者にとって、名前付きクラスほど発見しにくい

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Dart Pub package publisher

A library providing a tuple data structure.

Status - complete

We consider this package to be feature complete. With Dart 3.0, users now have the ability to use Records:

Records are an anonymous, immutable, aggregate type. Like other collection types, they let you bundle multiple objects into a single object.

  var record = (123, true);
  print('${record.$1}: ${record.$2}');

By and large, Records serve the same use cases that package:tuple had been used for. New users coming to this package should likely look at using Dart Records instead. Existing uses of package:tuple will continue to work, however we don't intend to enhance the functionality of this package; we will continue to maintain this package from the POV of bug fixes.

Usage example

const t = Tuple2<String, int>('a', 10);

print(t.item1); // prints 'a'
print(t.item2); // prints '10'
const t1 = Tuple2<String, int>('a', 10);
final t2 = t1.withItem1('c');
// t2 is a new [Tuple2] object with item1 is 'c' and item2 is 10.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト