validMnemonicWord function

bool validMnemonicWord(
  1. String word
)

Return true if a valid mnemonic word

Implementation

bool validMnemonicWord(String word) {
  // not a great implementation because it depends on the inner details of bip39
  try {
    // just need 3 words to avoid length error - append 2 valid words
    bip39.mnemonicToEntropy('${word.toLowerCase().trim()} ability able');
  } on ArgumentError {
    return false;
  } on StateError {
    return true; //StateError is not valid to this test
  }
  return true;
}