value_class 1.0.1
value_class: ^1.0.1 copied to clipboard
Code generation for value classes. This package depends on value_annotation.
Features #
By annotating the class, the code required for the "Value Class" is automatically generated.
Inspired by json_serializable and freezed.
Getting started #
Flutter project:
flutter pub add value_annotation
flutter pub add --dev build_runner
flutter pub add --dev value_class
flutter pub get
Dart project:
dart pub add value_annotation
dart pub add --dev build_runner
dart pub add --dev value_class
dart pub get
Usage #
1. Create class #
import 'package:value_annotation/value_annotation.dart';
part 'example.value.dart';
@valueClass
class Example with _$Example {
const factory Example(String value) = _Example;
const factory Example.fromJson(String value) = _Example;
}
2. Run generator #
Flutter project:
flutter pub run build_runner build
Dart project:
dart run build_runner build