Function-local enum definitions

Today, I realized that a Dart feature I didn’t know I wanted is to be able to define local enums.

I wrote this down as a feature request for the Dart team:

I’d be grateful for feedback here or on the github thread.

5 Likes

This is a great feature.

This discussion might be relevant since enums are basically a special kind of class in dart

1 Like

Since you are there (and since we still have inline functions available), what about inline classes? I used to love those in C#.

final class SomePublicClass {
  const SomePublicClass();

  ...

  final class _SomePrivateClass() {
  }
}