buildToolbar method
- BuildContext context,
- Rect globalEditableRegion,
- double textLineHeight,
- Offset selectionMidpoint,
- List<
TextSelectionPoint> endpoints, - TextSelectionDelegate delegate,
- ClipboardStatusNotifier? clipboardStatus,
- 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,
ClipboardStatusNotifier? 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 JidoujishoSelectionToolbar(
anchorAbove: anchorAbove,
anchorBelow: anchorBelow,
clipboardStatus: clipboardStatus!,
creatorAction: (creatorAction != null)
? () {
creatorAction?.call(
delegate.textEditingValue.selection
.textInside(delegate.textEditingValue.text),
);
delegate.hideToolbar();
}
: null,
sentenceAction: (sentenceAction != null)
? () {
sentenceAction?.call(
JidoujishoTextSelection(
text: delegate.textEditingValue.text,
range: TextRange(
start: delegate.textEditingValue.selection.start,
end: delegate.textEditingValue.selection.end,
),
),
);
delegate.hideToolbar();
}
: null,
searchAction: (searchAction != null)
? () {
searchAction?.call(
delegate.textEditingValue.selection
.textInside(delegate.textEditingValue.text),
);
delegate.hideToolbar();
}
: null,
stashAction: () {
stashAction(
delegate.textEditingValue.selection
.textInside(delegate.textEditingValue.text),
);
delegate.hideToolbar();
},
shareAction: () {
shareAction(
delegate.textEditingValue.selection
.textInside(delegate.textEditingValue.text),
);
delegate.hideToolbar();
},
handleCopy: canCopy(delegate) && allowCopy
? () => handleCopy(delegate, clipboardStatus)
: null,
handleCut:
canCut(delegate) && allowCut ? () => handleCut(delegate) : null,
handlePaste:
canPaste(delegate) && allowPaste ? () => handlePaste(delegate) : null,
handleSelectAll: canSelectAll(delegate) && allowSelectAll
? () => handleSelectAll(delegate)
: null,
);
}