PerfectTextController constructor

PerfectTextController({
  1. FocusNode? focusNode,
  2. bool selectAllOnFocus = false,
  3. bool readyOnly = false,
  4. void onTextChange(
    1. String value
    )?,
  5. void onFocusChange(
    1. bool value
    )?,
  6. List<DecorationStyle> decorations = const [],
})

Implementation

PerfectTextController({
  FocusNode? focusNode,
  bool selectAllOnFocus = false,
  bool readyOnly = false,
  this.onTextChange,
  this.onFocusChange,
  this.decorations = const [],
}) : focusNode = focusNode ??
          (readyOnly
              ? FocusNode(
                  skipTraversal: true,
                  canRequestFocus: false,
                  descendantsAreFocusable: false,
                  descendantsAreTraversable: false,
                )
              : FocusNode()) {
  this.focusNode.addListener(() {
    PerfectTextController.focused =
        this.focusNode.hasPrimaryFocus ? this : null;

    if (selectAllOnFocus) {
      onFocusChange?.call(this.focusNode.hasPrimaryFocus);
      if (this.focusNode.hasPrimaryFocus) {
        selectAll();
      }
    }
  });
}