enum_to_string 1.0.9 copy "enum_to_string: ^1.0.9" to clipboard
enum_to_string: ^1.0.9 copied to clipboard

outdated

Better conversion of ENUMs to string. Dart has annoying EnumName.ValueName syntax when calling enum.toString, this package fixes that.

example/main.dart

import 'package:enum_to_string/enum_to_string.dart';

enum TestEnum { ValueOne, Value2, valueThree }

main() {
  // Parse enum to a string
  EnumToString.parse(TestEnum.ValueOne); //ValueOne
  EnumToString.parse(TestEnum.Value2); //Value2
  EnumToString.parse(TestEnum.valueThree); //valueThree

  // Parse an enum to something more human readable
  EnumToString.parseCamelCase(TestEnum.ValueOne); //Value one
  EnumToString.parseCamelCase(TestEnum.Value2); //Value 2
  EnumToString.parseCamelCase(TestEnum.valueThree); //Value three

  // Get an enum from a string
  EnumToString.fromString(TestEnum.values, "ValueOne"); //, TestEnum.ValueOne
  EnumToString.fromString(TestEnum.values, "Value2"); // TestEnum.Value2
  EnumToString.fromString(TestEnum.values, "valueThree"); // TestEnum.valueThree

  // Get an enum from a string
  EnumToString.toList<TestEnum>(
      TestEnum.values); // {ValueOne, Value2, valuethree}
}
325
likes
0
pub points
98%
popularity

Publisher

unverified uploader

Better conversion of ENUMs to string. Dart has annoying EnumName.ValueName syntax when calling enum.toString, this package fixes that.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on enum_to_string