how to customise the toolbar for a flutter SelectableRegion

204 views Asked by At

When text in a SelectableRegion widget is selected, the toolbar generated by materialTextSelectionControls has options for 'Copy' and 'SelectAll'. What is the best way to disable 'SelectAll' and how can the styling (in particular, text color) of the options be changed?

1

There are 1 answers

1
Frank H On BEST ANSWER

So far, my answer to my question is to copy the relevant flutter files for the SelectableRegion widget and customise them to make a MySelectableRegion widget.

But surely there is a better way?

For anyone wanting to do the same as me, the files I copied and am editing are

flutter/packages/flutter/lib/src/widgets/selectable_region.dart

flutter/packages/flutter/lib/src/material/text_selection.dart 

flutter/packages/flutter/lib/src/material/text_selection_toolbar.dart