copyWith method Null safety

TextSelection copyWith(
  1. {int? baseOffset,
  2. int? extentOffset,
  3. TextAffinity? affinity,
  4. bool? isDirectional}
)

Creates a new TextSelection based on the current selection, with the provided parameters overridden.

Implementation

TextSelection copyWith({
  int? baseOffset,
  int? extentOffset,
  TextAffinity? affinity,
  bool? isDirectional,
}) {
  return TextSelection(
    baseOffset: baseOffset ?? this.baseOffset,
    extentOffset: extentOffset ?? this.extentOffset,
    affinity: affinity ?? this.affinity,
    isDirectional: isDirectional ?? this.isDirectional,
  );
}