TextSelectionOverlay constructor Null safety
- {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}
Creates an object that manages overlay entries for selection handles.
The context
must not be null and must have an Overlay as an ancestor.
Implementation
TextSelectionOverlay({
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,
);
}