enum_map 0.3.0 copy "enum_map: ^0.3.0" to clipboard
enum_map: ^0.3.0 copied to clipboard

A Map with compile-time check that every enum constant has an entry in it.

example/lib/main.dart

import 'package:enum_map/enum_map.dart';

part 'main.g.dart';

@enumMap
@unmodifiableEnumMap
enum Fruit {
  apple,
  orange,
  banana,
}

void main() {
  final modifiableMap = FruitMap<String>(apple: 'a', orange: 'o', banana: 'b',);
  print(modifiableMap);  // prints: {Fruit.apple: a, Fruit.orange: o, Fruit.banana: b}
  print(modifiableMap[Fruit.apple]);      // prints: a
  print(modifiableMap.get(Fruit.apple));  // prints: a

  const unmodifiableMap = UnmodifiableFruitMap<String>(apple: 'a', orange: 'o', banana: 'b',);
  print(unmodifiableMap);  // prints: {Fruit.apple: a, Fruit.orange: o, Fruit.banana: b}
  print(unmodifiableMap[Fruit.apple]);      // prints: a
  print(unmodifiableMap.get(Fruit.apple));  // prints: a
}
6
likes
160
pub points
46%
popularity

Publisher

verified publisherainkin.com

A Map with compile-time check that every enum constant has an entry in it.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT-0 (license)

More

Packages that depend on enum_map