MyGit

felangel/data_class

Fork: 10 Star: 297 (更新于 2024-12-13 07:40:11)

license: MIT

Language: Dart .

Experimental support for data classes in Dart using macros.

最后发布版本: v0.1.0 ( 2024-09-25 12:39:02)

官方网址 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

最近版本更新:(数据更新于 2024-10-04 23:30:39)

2024-09-25 12:39:02 v0.1.0

2024-06-02 12:21:04 v0.0.2

2024-05-27 09:23:22 v0.0.0-dev.12

2024-05-25 10:37:47 v0.0.0-dev.11

2024-05-24 13:13:38 v0.0.0-dev.10

2024-05-22 13:07:31 v0.0.0-dev.9

2024-05-21 13:00:55 v0.0.0-dev.8

2024-05-18 10:56:31 v0.0.0-dev.7

2024-05-17 22:27:32 v0.0.0-dev.6

2024-05-17 10:39:07 v0.0.0-dev.5

主题(topics):

dart, data-class, macros, struct

felangel/data_class同语言 Dart最近更新仓库

2024-12-27 11:08:06 KaringX/karing

2024-12-22 15:25:05 Xmarmalade/alisthelper

2024-12-19 13:46:32 3003h/Eros-FE

2024-12-14 22:23:30 guozhigq/pilipala

2024-12-09 02:47:22 KRTirtho/spotube

2024-12-09 00:51:26 chen08209/FlClash