enum_as_string 1.0.0+2 copy "enum_as_string: ^1.0.0+2" to clipboard
enum_as_string: ^1.0.0+2 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
150
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

Documentation

API reference

License

MIT (license)

More

Packages that depend on enum_as_string