struct_annotation 0.0.0-dev.2 copy "struct_annotation: ^0.0.0-dev.2" to clipboard
struct_annotation: ^0.0.0-dev.2 copied to clipboard

discontinuedreplaced by: data_class_macro

Experimental support for data classes in Dart using pkg:macros

example/main.dart

// TODO(felangel): remove once https://github.com/dart-lang/sdk/commit/73bdc86dd50e11cedb3bf976c597a02ad209bdb4 lands on master
// ignore: unnecessary_import
import 'package:struct_annotation/src/struct_annotation.dart';
import 'package:struct_annotation/struct_annotation.dart';

@Struct()
class Person {
  final String name;
  final int age;
}

void main() {
  const jane = Person(name: 'Jane', age: 42);
  final john = jane.copyWith(name: 'John');

  print(jane); // Person(name: Jane, age: 42)
  print(john); // Person(name: John, age: 42)

  print(jane == jane.copyWith()); // true
  print(john == john.copyWith(age: 21)); // false
}
11
likes
0
pub points
0%
popularity

Publisher

verified publisherbloc-dev.com

Experimental support for data classes in Dart using pkg:macros

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, equatable, macros

More

Packages that depend on struct_annotation