TextSelectionOverlay constructor

TextSelectionOverlay({
  1. required TextEditingValue value,
  2. required BuildContext context,
  3. Widget? debugRequiredFor,
  4. required LayerLink toolbarLayerLink,
  5. required LayerLink startHandleLayerLink,
  6. required LayerLink endHandleLayerLink,
  7. required RenderEditable renderObject,
  8. TextSelectionControls? selectionControls,
  9. bool handlesVisible = false,
  10. required TextSelectionDelegate selectionDelegate,
  11. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  12. VoidCallback? onSelectionHandleTapped,
  13. ClipboardStatusNotifier? clipboardStatus,
  14. WidgetBuilder? contextMenuBuilder,
  15. required TextMagnifierConfiguration magnifierConfiguration,
})

Creates an object that manages overlay entries for selection handles.

The context must have an Overlay as an ancestor.

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,
  );
}