SimilarityIndex constructor Null safety

const SimilarityIndex(
  1. String term,
  2. double similarity
)

Instantiate a const SimilarityIndex with the term and similarity parameters.

  • term is the suggested term and must be a non-empty String. An exception is thrown if term is empty.
  • similarity is the similarity level of the suggestion on a scale of 0.0 to 1.0, where 1.0 indicates the terms are identical. An exception is thrown if similarity is less than 0.0 or more than 1.0.

Implementation

const SimilarityIndex(this.term, this.similarity)
    : assert(term != '' && similarity >= 0.0 && similarity <= 1.0);