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}');
}

Libraries

convert_enum