Q: Passing enum type as argument in Dart 2 Just like passing class type as argument to method I want to pass enum, as I  want to write a general method which operates on enum.
I tried:
  void foo(E):
    print(E.values[0])

but it doesn't work.
Is there a way?

A: This might work for you
typedef EnumValues<T> = List<T> Function();

void main() {
  foo<E1>(() => E1.values);
  foo<E2>(() => E2.values);
}

enum E1 { a, b }
enum E2 { c, d }

void foo<T>(EnumValues<T> valuesFn) {
  var values = valuesFn();
  for (var v in values) {
    print(v);
  }
}

See comments - shorter version
void main() {
  foo<E1>(E1.values);
  foo<E2>(E2.values);
}

enum E1 { a, b }
enum E2 { c, d }

void foo<T>(List<T> values) {
  for (var v in values) {
    print(v);
  }
  print(values[0]);
}

