TextEditingValue.fromJSON constructor

TextEditingValue.fromJSON(
  1. Map<String, dynamic> encoded
)

Creates an instance of this class from a JSON object.

Implementation

factory TextEditingValue.fromJSON(Map<String, dynamic> encoded) {
  return TextEditingValue(
    text: encoded['text'] as String,
    selection: TextSelection(
      baseOffset: encoded['selectionBase'] as int ?? -1,
      extentOffset: encoded['selectionExtent'] as int ?? -1,
      affinity: _toTextAffinity(encoded['selectionAffinity'] as String) ?? TextAffinity.downstream,
      isDirectional: encoded['selectionIsDirectional'] as bool ?? false,
    ),
    composing: TextRange(
      start: encoded['composingBase'] as int ?? -1,
      end: encoded['composingExtent'] as int ?? -1,
    ),
  );
}