value_t_generator 0.1.0 copy "value_t_generator: ^0.1.0" to clipboard
value_t_generator: ^0.1.0 copied to clipboard

outdated

Generates code to create a value type including a copyWith method and handles extended and interfaces and their heirarchies

value_t #

Generates code to create a copywith class and implements all the getter fields in any extended or implemented classes.

Usage

  var a = MarkingIncorrect("my answer", <String>["blah", "blah"], "fullWord");

  print("a is MarkingState:" + (a is Marking).toString());

  var d = a.copyWith(answer: "blah");

Definition

abstract class Marking {}

abstract class IsCorrect {}

abstract class HasWord {
  String get word;
}

@ValueT() //will be made non abastract and getters created
abstract class $MarkingCorrectNoWord implements Marking, IsCorrect {}

@ValueT()
abstract class $MarkingCorrect implements Marking, HasWord, IsCorrect {}

@ValueT()
abstract class $MarkingIncorrect implements Marking, HasWord {
  String get answer;
  List<String> get infoMessages;
}

When defining your class put a dollar infront of the name and make it abstract #

abstract class $MyClass {

When defining the fields make them non-final getters #

    String get name;
}

When using your class in code remove the dollar #

var a = MyClass("Adrian");

See Marking_ValueT_extends and Marking_ValueT_implements in the example #

Inspirations #

Thanks for built_value and meta_types for inspiration (the dollar in front of the class names was copied from meta_types)

0
likes
25
pub points
0%
popularity

Publisher

unverified uploader

Generates code to create a value type including a copyWith method and handles extended and interfaces and their heirarchies

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

analyzer, build, collection, quiver, source_gen, value_t_annotation

More

Packages that depend on value_t_generator