buildToolbar method

  1. @override
Widget buildToolbar(
  1. BuildContext context,
  2. Rect globalEditableRegion,
  3. double textLineHeight,
  4. Offset selectionMidpoint,
  5. List<TextSelectionPoint> endpoints,
  6. TextSelectionDelegate delegate,
  7. ValueListenable<ClipboardStatus>? clipboardStatus,
  8. Offset? lastSecondaryTapDownPosition,
)
override

Builder for material-style copy/paste text selection toolbar.

Implementation

@override
Widget buildToolbar(
  BuildContext context,
  Rect globalEditableRegion,
  double textLineHeight,
  Offset selectionMidpoint,
  List<TextSelectionPoint> endpoints,
  TextSelectionDelegate delegate,
  ValueListenable<ClipboardStatus>? clipboardStatus,
  Offset? lastSecondaryTapDownPosition,
) {
  final TextSelectionPoint startTextSelectionPoint = endpoints[0];
  final TextSelectionPoint endTextSelectionPoint =
      endpoints.length > 1 ? endpoints[1] : endpoints[0];
  final Offset anchorAbove = Offset(
      globalEditableRegion.left + selectionMidpoint.dx,
      globalEditableRegion.top +
          startTextSelectionPoint.point.dy -
          textLineHeight -
          _kToolbarContentDistance);
  final Offset anchorBelow = Offset(
    globalEditableRegion.left + selectionMidpoint.dx,
    globalEditableRegion.top +
        endTextSelectionPoint.point.dy +
        _kToolbarContentDistanceBelow,
  );

  return FormattedTextToolbar(
    anchorAbove: anchorAbove,
    anchorBelow: anchorBelow,
    clipboardStatus: clipboardStatus,
    delegate: delegate,
    items: actions,
    handleCopy: canCopy(delegate) ? () => handleCopy(delegate) : null,
    handleCut: canCut(delegate) ? () => handleCut(delegate) : null,
    handlePaste: canPaste(delegate) ? () => handlePaste(delegate) : null,
    handleSelectAll:
        canSelectAll(delegate) ? () => handleSelectAll(delegate) : null,
  );
}