enum_as_string 1.0.0 copy "enum_as_string: ^1.0.0" to clipboard
enum_as_string: ^1.0.0 copied to clipboard

discontinued
outdated

Utility library for enum-to-string and string-to-enum conversions. Nothing more, nothing less.

example/example.dart

import 'package:enum_as_string/enum_as_string.dart';

enum Countries { hoofset, crayland, gabbard }

void main() {
  print(Enum.asString(Countries.hoofset)); // 'hoofset'
  print(Enum.asString(Countries.crayland)); // 'crayland'
  print(Enum.asString(Countries.gabbard)); // 'gabbard'
  print(Enum.asString('Not an enum')); // 'Not an enum'

  print(Enum.fromString(Countries.values, 'hoofset')); // 'Countries.hoofset'
  print(Enum.fromString(Countries.values, 'crayland')); // 'Countries.crayland'
  print(Enum.fromString(Countries.values, 'gabbard')); // 'Countries.gabbard'
  print(Enum.fromString(Countries.values, 'inexistentCountry')); // null
}
1
likes
0
pub points
3%
popularity

Publisher

unverified uploader

Utility library for enum-to-string and string-to-enum conversions. Nothing more, nothing less.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on enum_as_string