SelectableDeltaTextView class

Выделяемый текст на базе EditableText с фиксацией якоря выделения (base) во время drag.

Материаловский SelectableText опирается на встроенную во Flutter компенсацию скролла, которая при пересчёте позиции анкора учитывает только ось ближайшего Scrollable (axisDirectionToAxis) и игнорирует его направление. Для списка с reverse: true (лента чата) position.pixels растёт в обратную сторону, поэтому при автоскролле знак компенсации оказывается неверным и якорь «уезжает» на строки, пропорционально прокрутке. Баг живёт сразу в двух местах TextSelectionGestureDetectorBuilder с общими полями _scrollPosition/_dragStartScrollOffset: onDragSelectionUpdate (мышиный drag на десктопе, SelectionChangedCause.drag) и onSingleLongTapMoveUpdate (long-press + протяжка пальцем на тач-платформах, SelectionChangedCause.longPress).

Здесь используется тот факт, что при обоих жестах якорь (base) обязан оставаться в точке старта и меняться не должен — двигается только extent. Мы запоминаем base в момент старта жеста (когда выделение схлопнуто) и на каждом последующем изменении с той же причиной возвращаем его на место через контроллер. Extent при этом обновляется штатно, поэтому выделение продолжает следовать за указателем, но левая/правая граница больше не смещается при автоскролле ленты.

Inheritance

Constructors

SelectableDeltaTextView({required TextSpan textSpan, required FocusNode focusNode, Key? key, int? maxLines, TextAlign textAlign = TextAlign.start, Color? selectionColor, VoidCallback? onTap, void onSelectionChanged(TextSelection selection, SelectionChangedCause? cause)?, Widget contextMenuBuilder(BuildContext, EditableTextState)?})
const

Properties

contextMenuBuilder Widget Function(BuildContext, EditableTextState)?
final
focusNode FocusNode
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxLines int?
final
onSelectionChanged → void Function(TextSelection selection, SelectionChangedCause? cause)?
final
onTap VoidCallback?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionColor Color?
final
textAlign TextAlign
final
textSpan TextSpan
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SelectableDeltaTextView>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited