stateCodeToName method

String stateCodeToName({
  1. required String code,
})

Resolves a Region.stateCode to its name

Returns: state name, if found, otherwise the provided code

Implementation

String stateCodeToName({required String code}) {
  var codeLowered = code.toLowerCase();
  return states
          .firstWhereOrNull((s) => s.stateCode.toLowerCase() == codeLowered)
          ?.name ??
      code;
}