enum DevMode {
  mock,
  emulator,
  real;

  @override
  String toString() => name;

  /// Tries to parse String and returns mode. Fallback is returned if there 
  /// is an error during parsing.
  static DevMode fromString(String? mode, {DevMode fallback = DevMode.mock}) {
    for (final m in values) {
      if (m.name == mode) {
        return m;
      }
    }

    return fallback;
  }
}
