toBeginningOfSentenceCase function

String? toBeginningOfSentenceCase(
  1. String? input,
  2. [String? locale]
)

Convert a string to beginning of sentence case, in a way appropriate to the locale.

Currently this just converts the first letter to uppercase, which works for many locales, and we have the option to extend this to handle more cases without changing the API for clients. It also hard-codes the case of dotted i in Turkish and Azeri.

Implementation

String? toBeginningOfSentenceCase(String? input, [String? locale]) {
  if (input == null || input.isEmpty) return input;
  return '${_upperCaseLetter(input[0], locale)}${input.substring(1)}';
}