ExtendedTextSelectionOverlay constructor

ExtendedTextSelectionOverlay({
  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 ExtendedTextSelectionRenderObject renderObject,
  8. TextSelectionControls? selectionControls,
  9. bool handlesVisible = false,
  10. required TextSelectionDelegate selectionDelegate,
  11. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  12. VoidCallback? onSelectionHandleTapped,
  13. ClipboardStatusNotifier? clipboardStatus,
})

Creates an object that manages overly entries for selection handles.

The context must not be null and must have an Overlay as an ancestor.

Implementation

ExtendedTextSelectionOverlay({
  required TextEditingValue value,
  required BuildContext 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,
})  : assert(value != null),
      assert(context != null),
      assert(handlesVisible != null),
      _handlesVisible = handlesVisible,
      _value = value {
  renderObject.selectionStartInViewport
      .addListener(_updateTextSelectionOverlayVisibilities);
  renderObject.selectionEndInViewport
      .addListener(_updateTextSelectionOverlayVisibilities);
  _updateTextSelectionOverlayVisibilities();
  _selectionOverlay = SelectionOverlay(
    context: context,
    debugRequiredFor: debugRequiredFor,
    // The metrics will be set when show handles.
    startHandleType: TextSelectionHandleType.collapsed,
    startHandlesVisible: _effectiveStartHandleVisibility,
    lineHeightAtStart: 0.0,
    onStartHandleDragStart: _handleSelectionStartHandleDragStart,
    onStartHandleDragUpdate: _handleSelectionStartHandleDragUpdate,
    endHandleType: TextSelectionHandleType.collapsed,
    endHandlesVisible: _effectiveEndHandleVisibility,
    lineHeightAtEnd: 0.0,
    onEndHandleDragStart: _handleSelectionEndHandleDragStart,
    onEndHandleDragUpdate: _handleSelectionEndHandleDragUpdate,
    toolbarVisible: _effectiveToolbarVisibility,
    selectionEndPoints: const <TextSelectionPoint>[],
    selectionControls: selectionControls,
    selectionDelegate: selectionDelegate,
    clipboardStatus: clipboardStatus,
    startHandleLayerLink: startHandleLayerLink,
    endHandleLayerLink: endHandleLayerLink,
    toolbarLayerLink: toolbarLayerLink,
    onSelectionHandleTapped: onSelectionHandleTapped,
    dragStartBehavior: dragStartBehavior,
    toolbarLocation: renderObject.lastSecondaryTapDownPosition,
  );
}