parseDictationResultToNumeric function

String? parseDictationResultToNumeric(
  1. String? result
)

Implementation

String? parseDictationResultToNumeric(String? result) {
  if (result == null) {
    return null;
  }

  var text = result.toLowerCase().trim();
  if (text.startsWith('number ')) {
    text = text.substring(7);
  }

  switch (text) {
    case 'zero':
      return '0';
    case 'one':
      return '1';
    case 'two':
      return '2';
    case 'three':
      return '3';
    case 'four':
      return '4';
    case 'five':
      return '5';
    case 'six':
      return '6';
    case 'seven':
      return '7';
    case 'eight':
      return '8';
    case 'nine':
      return '9';
    case 'ten':
      return '10';
    case 'eleven':
      return '11';
    case 'twelve':
      return '12';
  }

  return double.tryParse(text)?.toString();
}