parse static method

AppArchitecture parse(
  1. String value
)

Parse a user-supplied value. Throws FormatException on unknown input.

Implementation

static AppArchitecture parse(String value) {
  final v = value.toLowerCase().replaceAll(RegExp(r'[\s_-]'), '');
  switch (v) {
    case 'clean':
    case 'cleanarchitecture':
      return AppArchitecture.clean;
    case 'mvvm':
      return AppArchitecture.mvvm;
    case 'featurefirst':
    case 'feature':
      return AppArchitecture.featureFirst;
    case 'simple':
    case 'none':
      return AppArchitecture.simple;
    default:
      throw FormatException(
        'Unknown architecture "$value". '
        'Valid: clean, mvvm, feature-first, simple.',
      );
  }
}