fromString static method

DexEnum fromString(
  1. String value
)

Creates a DexEnum from a string value.

If the string matches a known DEX name, returns the corresponding enum value. Otherwise, throws an ArgumentError.

final dex = DexEnum.fromString('Whirlpool'); // Returns DexEnum.whirlpool

Implementation

static DexEnum fromString(String value) {
  return DexEnum.values.firstWhere(
    (dex) => dex.value.toLowerCase() == value.toLowerCase(),
    orElse: () => throw ArgumentError('Unknown DEX: $value'),
  );
}