Horje
Dart enum to string Code Example
dart enum
enum Status { 
   none, 
   running, 
   stopped, 
   paused 
}  
void main() { 
   print(Status.values); 
   Status.values.forEach((v) => print('value: $v, index: ${v.index}'));
   print('running: ${Status.running}, ${Status.running.index}'); 
   print('running index: ${Status.values[1]}'); 
}
Dart enum to string
enum Topic { none, computing, general }

extension TopicString on String {
  Topic get topic {
    switch (this) {
      case 'computing':
        return Topic.computing;
      case 'general':
        return Topic.general;
      case 'none':
        return Topic.none;
    }
  }
}

extension TopicExtension on Topic {
  String get string {
    switch (this) {
      case Topic.computing:
        return 'computing';
      case Topic.general:
        return 'general';
      case Topic.none:
        return 'none';
    }
  }
}
dart enum from string
Fruit f = Fruit.values.firstWhere((e) => e.toString() == 'Fruit.' + str);




Whatever

Related
dockerfile nginx example Code Example dockerfile nginx example Code Example
width : double.infinite Code Example width : double.infinite Code Example
maths.abs function in java Code Example maths.abs function in java Code Example
mongoose select nested Code Example mongoose select nested Code Example
flutter path provider Code Example flutter path provider Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7