match method

  1. @override
List<List<ReverseMatch>> match(
  1. String password
)
override

Should return the matches for the password.

A synchronous matcher should return a list (usually of length 1) of lists of matches. An asynchronous matcher can return a list of futures that completes with a list of matches.

Implementation

@override
List<List<ReverseMatch>> match(String password) {
  final String reversedPassword = password.split('').reversed.join('');
  return <List<ReverseMatch>>[
    dictionaryMatcher
        .match(reversedPassword)[0]
        .map((DictionaryMatch match) => match.toReverseMatch())
        .where((ReverseMatch match) {
      // Ignore palindromes because they're matched as a dictionary match.
      return match.token.toLowerCase() != match.matchedWord;
    }).toList(),
  ];
}