---
title: "Discussion on \"Everything you need to know about Enum with Flutter and Dart\" | Hashnode"
description: "Discussion on \"Everything you need to know about Enum with Flutter and Dart\". Enumerations, often abbreviated by enum, are special class types that allow a limited number of constants to be represented.\nWhy use an enum rather than a class?\nEnum makes it possible to represent a limited number of constants, allowing better reada..."
url: "https://hashnode.com/posts/everything-you-need-to-know-about-enum-with-flutter-and-dart/651bfdf02198838db882ff54"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Everything you need to know about Enum with Flutter and Dart](https://lyabs.hashnode.dev/everything-you-need-to-know-about-enum-with-flutter-and-dart?utm_source=hashnode&utm_medium=feed)

Enumerations, often abbreviated by enum, are special class types that allow a limited number of constants to be represented. Why use an enum rather than a class? Enum makes it possible to represent a limited number of constants, allowing better reada...

Oct 3, 2023 · 3 min read · lyabs.hashnode.dev  
Read the article

-   [#flutter](https://hashnode.com/tag/flutter)
-   [#dart](https://hashnode.com/tag/dart)
-   [#enum](https://hashnode.com/tag/enum)
-   [#enumeration](https://hashnode.com/tag/enumeration)
-   [#guide](https://hashnode.com/tag/guide)

## Written by

[Loïc Yabili](https://hashnode.com/@lyabs243)

@lyabs243 · Lubumbashi, DR Congo

  
[View profile](https://hashnode.com/@lyabs243)

Freelance mobile developer specializing in cross-platform development with Flutter. I'm also interested in back-end technologies: PHP, node

I am a mobile software developer specializing in Flutter. I provide quality services to clients. In my journey I worked with 40+ satisfied clients across the world and successfully completed 70+ orders.

## Responses 2

Markdown supported · ⌘↵ to post

[Diego Ponce de León](https://hashnode.com/@xleon)

[Oct 7, 2023](https://hashnode.com/posts/everything-you-need-to-know-about-enum-with-flutter-and-dart/651bfdf02198838db882ff54/comment/6521c3fd638bfabf653582b0)

I'm trying to digest Dart right now (coming from C#) and this particular enum thing is more than awesome. I have many ideas to implement your example.

However I'm missing enum flags available in other languages. Turns out there is a library though: [pub.dev/packages/enum\_flag](https://pub.dev/packages/enum_flag) but I think it should be part of the language.

[Loïc Yabili](https://hashnode.com/@lyabs243)

[Oct 9, 2023](https://hashnode.com/posts/everything-you-need-to-know-about-enum-with-flutter-and-dart/651bfdf02198838db882ff54/comment/6521c3fd638bfabf653582b0#reply-6523ab4b37d5d7cd95103465)

Thank you Diego for your feedback.

For the moment the enum flag is not natively integrated in Dart, I agree with you, it will be a great option like on C#.

[Yohanes Bandung](https://hashnode.com/@ybbond)

[Oct 4, 2023](https://hashnode.com/posts/everything-you-need-to-know-about-enum-with-flutter-and-dart/651bfdf02198838db882ff54/comment/651cfc7dc64d5e99595a0580)

Great information!

We get the ability to add default value if mapping to enum use non-assigned value.

do you have any idea how we can get default value if the enum is nullable? for example:

```
final WeekDay? weekDay = null;

// I want to get empty string
final String weekDayShortName = weekDay.shortName;
```

previously, I use something like this:

```
enum WeekDay {
  monday
}

// extend nullable WeekDay
extension WeekDayExtension on WeekDay? {
  String get shortName {
    switch (this) {
      case WeekDay.monday:
        return 'Mon';
      case null:
        return '';
    }
  }
}
```

[Loïc Yabili](https://hashnode.com/@lyabs243)

[Oct 4, 2023](https://hashnode.com/posts/everything-you-need-to-know-about-enum-with-flutter-and-dart/651bfdf02198838db882ff54/comment/651cfc7dc64d5e99595a0580#reply-651d29baf561999bd60fa18f)

Thank you for your comment.

If the enum is nullable it can't be used without the null aware operator '?', for me there is not need to add a case for that, you can directly use:

`final String weekDayShortName = weekDay?.shortName?? '';`
