カテゴリー・パッケージ・リポジトリを検索

GitHub リポジトリfelangel/data_class

data_class

マクロを使用したDartにおけるデータクラスの実験的サポート。

data_class のプロジェクト画像
スター
297
フォーク
14
最終プッシュ(UTC)
2024/10/16
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

data_class

build pub package License: MIT

Support for data classes in Dart using macros.

✨ Features

🪨 const constructors with required, named parameters

🖨️ copyWith with optional, nullable, named parameters

✨ toString for an improved string representation

☯️ operator== and hashCode for value equality

🧑‍💻 Example

import 'package:data_class/data_class.dart';

@Data()
class Person {
  final String name;
}

void main() {
  // 🪨 Create a const instance with required, name parameters.
  const dash = Person(name: 'Dash');

  // 🖨️ Create copies of your object.
  final sparky = dash.copyWith(name: 'Sparky');

  // ✨ Human-readable string representation.
  print(dash); // Person(name: Dash)
  print(sparky); // Person(name: Sparky)

  // ☯️ Value equality comparisons.
  print(dash == dash.copyWith()); // true
  print(dash == sparky); // false
}

🚀 Quick Start

  1. Add package:data_class to your pubspec.yaml

    dependencies:
      data_class: any
    
  2. Enable experimental macros in analysis_options.yaml

    analyzer:
      enable-experiment:
        - macros
    
  3. Use the @Data annotation (see above example).

  4. Run it

    dart --enable-experiment=macros run main.dart
    

*Requires Dart SDK >= 3.5.0

Felix Angelov GitHub avatar
GitHub 作者

Felix Angelov ↗

software engineer by day, software engineer by night.

言語Dart

カテゴリー

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 4 件

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗