Enum In Dart

Dart enum :

Enum In Dart
  • Group of named constants
  • enum is a keyword.
  • Zero based index starting from 0, 1, 2,…

For example :

enum Result { 
      LoginSuccess, 
      LoginFail
 }
void main(){
      var result = Result.LoginSuccess;
 switch(result){
      case Result.LoginSuccess:
           print("Login successfully");
           break;
      case Result.LoginFail:
           print("Mobile or email invalid");
           break;
 }
}

Output: Login successfully

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in