convert_enum 0.1.0
convert_enum: ^0.1.0 copied to clipboard

Simple Enum <-> String converter

convert_enum #

Simple utility to convert Enums <-> String.

Getting Started #

To use this plugin, add convert_enum as a dependency in your pubspec.yaml file.

Example #

import 'package:convert_enum/convert_enum.dart';

enum MyEnum {
  ITEM1,
  ITEM2,
  ITEM3,
}

void main() {
  MyEnum aEnum = MyEnum.ITEM1;
  String aString = 'ITEM1';

  MyEnum convertedEnum = ConvertEnum().fromString(aString, MyEnum.values);
  print('aEnum == convertedEnum ${aEnum == convertedEnum}');

  String convertedString = ConvertEnum().string(aEnum);
  print('aString == convertedString ${aString == convertedString}');
}
1
likes
80
pub points
1%
popularity

Simple Enum <-> String converter

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on convert_enum