TextEditingValue constructor Null safety

const TextEditingValue(
  1. {String text = '',
  2. TextSelection selection = const TextSelection.collapsed(offset: -1),
  3. TextRange composing = TextRange.empty}

Creates information for editing a run of text.

The selection and composing range must be within the text. This is not checked during construction, and must be guaranteed by the caller.

The text, selection, and composing arguments must not be null but each have default values.

The default value of selection is TextSelection.collapsed(offset: -1). This indicates that there is no selection at all.


const TextEditingValue({
  this.text = '',
  this.selection = const TextSelection.collapsed(offset: -1),
  this.composing = TextRange.empty,
}) : assert(text != null),
     // The constructor does not verify that `selection` and `composing` are
     // valid ranges within `text`, and is unable to do so due to limitation
     // of const constructors. Some checks are performed by assertion in
     // other occasions. See `_textRangeIsValid`.
     assert(selection != null),
     assert(composing != null);