fromValue static method Null safety

CompressFormat? fromValue(
  1. String? value
)

Implementation

static CompressFormat? fromValue(String? value) {
  if (value != null) {
    try {
      return CompressFormat.values
          .firstWhere((element) => element.toValue() == value);
    } catch (e) {
      return null;
    }
  }
  return null;
}