Collation constructor

Collation({
  1. Locale? locale,
  2. Usage usage = Usage.sort,
  3. Sensitivity? sensitivity,
  4. bool ignorePunctuation = false,
  5. bool? numeric,
  6. CaseFirst? caseFirst,
  7. String? collation,
})

Creates a new locale-sensitive string comparator.

The comparison rules are configured using the provided parameters:

  • locale: The specific locale to use for comparison. If null, the system's current locale is used.
  • usage: Specifies the primary intent for the comparison, either for sorting a list or for searching within text (e.g., ignoring accents). Defaults to Usage.sort.
  • sensitivity: Determines the level of difference required for strings to be considered unequal. For example, controlling whether only base letters, accents, or case are considered. If null, the default for the locale is used.
  • ignorePunctuation: If true, punctuation characters are ignored during comparison. Defaults to false.
  • numeric: If true, treats sequences of digits as numerical values for comparison (e.g., '10' comes after '2'). If null, the default for the locale is used.
  • caseFirst: Specifies if upper- or lowercase letters should be sorted first. If null, the default for the locale is used.
  • collation: A specific collation algorithm to use (e.g., 'phonebook' or 'dictionary'). If null, the default collation for the locale is used.

Implementation

Collation({
  Locale? locale,
  Usage usage = Usage.sort,
  Sensitivity? sensitivity,
  bool ignorePunctuation = false,
  bool? numeric,
  CaseFirst? caseFirst,
  String? collation,
}) : _collationImpl = CollationImpl.build(
       locale ?? findSystemLocale(),
       CollationOptions(
         usage: usage,
         sensitivity: sensitivity,
         ignorePunctuation: ignorePunctuation,
         numeric: numeric,
         caseFirst: caseFirst,
         collation: collation,
       ),
     );