Generalize super_selectable_text to super_text #495
Replies: 3 comments
-
@miguelcmedeiros @venkatd @Jethro87 - can each of you take a look at this proposal and let me know what you think? |
Beta Was this translation helpful? Give feedback.
-
@matthew-carroll I think super_text makes sense as a package name. In the future, other things related purely to text could live in this package. Perhaps SuperTextField could be named something like SuperTextOverlay? Or is that too similar to the Overlay in the Flutter framework? I would expect SuperSelectableText to be like SelectableText, but better. Like how SuperTextField is like TextField, but better. So, if we rename it, we might want to re-introduce a SuperSelectableText that composes the gesture detection and the painting so it's got a batteries-included usage. |
Beta Was this translation helpful? Give feedback.
-
@matthew-carroll The widget that does not include gesture detection (handle by caller like in We could consider that This way the package can offer a high-level widget ( |
Beta Was this translation helpful? Give feedback.
-
super_editor
has a widget calledSuperSelectableText
, which renders text with a selection and a caret (but no gestures).SuperSelectableText
currently supports a single text selection and a single caret. This support needs to expand to include multiple selections and multiple carets.This is a good time to consider the most appropriate way to further generalize
SuperSelectableText
.Generalizing for multiple selections
My first thought about generalizing
SuperSelectableText
is to go from one constructor, to three constructors, as follows:The
custom()
constructor takes widget builders, which are also provided aTextLayout
to paint and position content based on text layout:Including selection gestures
We recently extracted
SuperSelectableText
andTextLayout
into a new package calledsuper_selectable_text
.Developers might use this package directly, for non-document use-cases. For this reason, we should consider adding support for selection gestures within the
super_selectable_text
package.We could provide gesture support in at least two ways. First, we could provide a widget that adds a
GestureDetector
:A limitation of this approach is that the selection widget has to choose the specific type of
SuperSelectableText
(single selection vs multi-selection). We could resolve that limitation by taking in abuilder
that creates the desiredSuperSelectableText
, which gives the developer the choice about how to build aSuperSelectableText
.A second approach would be to use the foreground builder in
SuperSelectableText
to respond to gestures:Here, again, if the above
build()
method is placed within a widget insuper_selectable_text
, then this widget has to impose the configuration of the innerSuperSelectableText
, which is constricting for app devs. On the other hand, we could offer developers just theGestureDetector
that goes in theforegroundBuilder
and then let app devs assemble, as desired.New package name and widget name
Given that
super_selectable_text
includes an interface calledTextLayout
, I'm wondering if the package should instead be calledsuper_text
.Additionally, if we add new widgets/APIs for selection gestures, is the
SuperSelectableText
widget still named correctly? TheSuperSelectableText
widget paints a selection and caret, but it doesn't include gesture support. The division between painting and gestures is a good thing, but the name might suggest to users that it includes gestures, when it doesn't. Is there a better name?Beta Was this translation helpful? Give feedback.
All reactions