enum_map 0.4.0-1.dev copy "enum_map: ^0.4.0-1.dev" to clipboard
enum_map: ^0.4.0-1.dev 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';

@MakeMap()
@MakeUnmodifiableMap()
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
0
pub points
49%
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

License

unknown (license)

Dependencies

macro_util, macros, meta

More

Packages that depend on enum_map