enum_string_value_generator 0.0.1+1
enum_string_value_generator: ^0.0.1+1 copied to clipboard
Now your enum classes have String values!!
Generator of enum_string_value
.
Usage #
(See whole example project)
Put build.yaml
on the root of your project.
targets:
$default:
builders:
enum_string_value_generator|enumHasValueBuilder:
generate_for:
- lib/*.dart
copied to clipboard
Add packages to your pubspec.yaml
.
dependencies:
enum_string_value_lib: ^0.0.1
dev_dependencies:
build_runner: ^1.7.2
enum_string_value_generator: ^0.0.1
copied to clipboard
Add @Value
annotation to your enum values and part
directive for the generated file.
// os.dart
import 'package:enum_string_value_lib/enum_string_value_lib.dart';
part "os.value.g.dart";
enum OsKind {
@Value("Android")
android,
@Value("iOS")
ios,
}
copied to clipboard
Run build_runner
on your project.
$ pub run build_runner build
copied to clipboard