'Add custom ToolbarOptions for selected text in Flutter

By default ToolbarOptions contains copy, cut, paste, selectAll options. Can we add a custom action? For example, an action which will keep the selected text and remove unselected one.



Solution 1:[1]

It's currently not possible in flutter, you can only control show or don't show default actions by the toolbarOptions property of TextField.

There is a pull request on github to add this functionality but it's not fully done.

Solution 2:[2]

You can use Selectable to customize the toolbar options and assign actions upon press. You can also grab the selected text.

https://pub.dev/packages/selectable

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pegasis
Solution 2 E G