TextSelectionOverlay constructor
- required TextEditingValue value,
- required BuildContext context,
- Widget? debugRequiredFor,
- required LayerLink toolbarLayerLink,
- required LayerLink startHandleLayerLink,
- required LayerLink endHandleLayerLink,
- required RenderEditable renderObject,
- TextSelectionControls? selectionControls,
- bool handlesVisible = false,
- required TextSelectionDelegate selectionDelegate,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- VoidCallback? onSelectionHandleTapped,
- ClipboardStatusNotifier? clipboardStatus,
- WidgetBuilder? contextMenuBuilder,
- required TextMagnifierConfiguration magnifierConfiguration,
Creates an object that manages overlay entries for selection handles.
Implementation
TextSelectionOverlay({
required TextEditingValue value,
required this.context,
Widget? debugRequiredFor,
required LayerLink toolbarLayerLink,
required LayerLink startHandleLayerLink,
required LayerLink endHandleLayerLink,
required this.renderObject,
this.selectionControls,
bool handlesVisible = false,
required this.selectionDelegate,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
VoidCallback? onSelectionHandleTapped,
ClipboardStatusNotifier? clipboardStatus,
this.contextMenuBuilder,
required TextMagnifierConfiguration magnifierConfiguration,
}) : _handlesVisible = handlesVisible,
_value = value {
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/widgets.dart',
className: '$TextSelectionOverlay',
object: this,
);
}
renderObject.selectionStartInViewport.addListener(_updateTextSelectionOverlayVisibilities);
renderObject.selectionEndInViewport.addListener(_updateTextSelectionOverlayVisibilities);
_updateTextSelectionOverlayVisibilities();
_selectionOverlay = SelectionOverlay(
magnifierConfiguration: magnifierConfiguration,
context: context,
debugRequiredFor: debugRequiredFor,
// The metrics will be set when show handles.
startHandleType: TextSelectionHandleType.collapsed,
startHandlesVisible: _effectiveStartHandleVisibility,
lineHeightAtStart: 0.0,
onStartHandleDragStart: _handleSelectionStartHandleDragStart,
onStartHandleDragUpdate: _handleSelectionStartHandleDragUpdate,
onEndHandleDragEnd: _handleAnyDragEnd,
endHandleType: TextSelectionHandleType.collapsed,
endHandlesVisible: _effectiveEndHandleVisibility,
lineHeightAtEnd: 0.0,
onEndHandleDragStart: _handleSelectionEndHandleDragStart,
onEndHandleDragUpdate: _handleSelectionEndHandleDragUpdate,
onStartHandleDragEnd: _handleAnyDragEnd,
toolbarVisible: _effectiveToolbarVisibility,
selectionEndpoints: const <TextSelectionPoint>[],
selectionControls: selectionControls,
selectionDelegate: selectionDelegate,
clipboardStatus: clipboardStatus,
startHandleLayerLink: startHandleLayerLink,
endHandleLayerLink: endHandleLayerLink,
toolbarLayerLink: toolbarLayerLink,
onSelectionHandleTapped: onSelectionHandleTapped,
dragStartBehavior: dragStartBehavior,
toolbarLocation: renderObject.lastSecondaryTapDownPosition,
);
}