crdt_lf_flutter library
Flutter reactivity for crdt_lf package.
Widgets that make it easier to use crdt_lf within Flutter systems.
Classes
- CrdtAwarenessCursor
-
A collaborator's pointer (a mouse-style presence cursor) to draw over a
pane: identity, paint color, the pointer position normalized into
[0, 1](so cursors map correctly across windows of different sizes) and an optional per-cursor style. - CrdtAwarenessCursorMarker
- The standalone visual marker for a single collaborator's pointer: a Figma-style arrow and an optional name bubble. Positioning is the caller's job (its top-left sits at the pointer) — CrdtAwarenessCursorsBuilder and CrdtAwarenessCursorsOverlay place it for you.
- CrdtAwarenessCursorsBuilder
- The transport/layout half of the presence overlay: it lays remote pointers over child (positioning each at its normalized CrdtAwarenessCursor.position) and reports the local pointer through onLocalPointer, but delegates the look of every cursor to builder.
- CrdtAwarenessCursorsOverlay
- Overlays the mouse-style presence cursors of remote collaborators on top of child, and reports the local pointer through onLocalPointer so the app can publish it on its presence channel.
- CrdtAwarenessCursorStyle
- The full look of a CrdtAwarenessCursorMarker: the color (pointer arrow and name-bubble background), the labelStyle of the name text and the marker geometry.
- CrdtBuilder
-
Rebuilds builder on every update of the ambient
CRDTDocument— local edits, applied remote changes and snapshot imports. -
CrdtEditorBinder<
V, D extends ComposableDelta< D> > - Binds an editor to the handler registered under id, through a CrdtEditorBinding it owns.
-
CrdtEditorBinding<
V, D extends ComposableDelta< D> > - Keeps an editor and one handler in step, both ways.
-
CrdtHandlerBuilder<
H extends Handler> - Rebuilds builder with the handler registered under id, only when that handler changes — a change applied to it (local or remote), a snapshot import, or (when nested) a change to a descendant handler.
-
CrdtHandlerDeltaBuilder<
V, D extends ComposableDelta< D> > - Rebuilds builder once per change, with the value already moved by what that change did.
-
CrdtHandlerDeltaListener<
V, D extends ComposableDelta< D> > - Invokes onDelta with what changed in the handler registered under id, one call per change, as a side effect.
-
CrdtHandlerListener<
H extends Handler> - Invokes listener as a side effect (not a rebuild) whenever the handler registered under id changes — a change applied to it, a snapshot import, or (when nested) a descendant change.
-
CrdtHandlerSelector<
H extends Handler, R> -
Rebuilds builder only when the value selected from the handler id
changes (compared with
==). - CrdtHistoryScope
- Shows the ambient document frozen at a point of its history.
- CrdtProvider
-
Provides a
CRDTDocumentto its subtree - CrdtRichTextEditingController
-
A TextEditingController that paints its text from
RichTextSpans. - CrdtRichTextFieldBuilder
-
Binds a CrdtRichTextEditingController to the
CRDTFugueRichTextHandlerregistered under id. -
CrdtSelector<
R> -
Rebuilds builder only when the value returned by selector changes
(compared with
==). - CrdtTextCursor
- A collaborator's text cursor to draw over a text field: identity, paint style and the stable anchors of their selection.
- CrdtTextCursorsOverlay
-
Paints the carets and selections of remote collaborators over child
(the subtree containing the
TextFieldbound to the same handler id). targetOf picks another editor. - CrdtTextCursorsTarget
- The text editor that CrdtTextCursorsOverlay paints over.
- CrdtTextFieldBuilder
-
Binds a TextEditingController to the text handler registered under id
(
CRDTTextHandlerorCRDTFugueTextHandler): -
HandlerDeltaSubscription<
V, D extends ComposableDelta< D> > - Follows one handler's delta stream on behalf of one consumer.
- RichTextEcho
- What one write of a RichTextWriter puts in the handler, to tell its echo from a foreign change.
- RichTextWriter
-
Writes edits of a rich text editor into a
CRDTFugueRichTextHandler. - SelectionAnchors
- The stable anchors of the selection of an editor, and what the editor publishes of them.
- SelectionAnchorsFocus
- Tells anchors whether the focus is inside child, and asks for no focus of its own.
- TextDelta
- A single contiguous text edit: at index, deleted code units are removed and inserted is inserted.
Enums
- CrdtTextCursorLabelPlacement
- Where CrdtTextCursorsOverlay draws a cursor's name tag, relative to the caret.
Extensions
- CrdtContextHelper on BuildContext
-
Convenience access to the ambient
CRDTDocument. - ReadContext on BuildContext
- Exposes the read method.
- SelectContext on BuildContext
-
Adds a
selectmethod on BuildContext. - WatchContext on BuildContext
- Exposes the watch method.
Constants
- crdtRichTextFieldOrigin → const Object
- The origin of every write CrdtRichTextFieldBuilder makes to the handler.
Properties
- debugVerifyCrdtRichTextFieldProjection ↔ bool
-
Whether CrdtRichTextFieldBuilder compares its whole content against the
handler.
getter/setter pair
- debugVerifyCrdtTextFieldProjection ↔ bool
-
Whether CrdtTextFieldBuilder compares its whole text against the handler.
getter/setter pair
Functions
-
computeTextDelta(
String oldText, String newText, {int? caret}) → TextDelta? -
Computes the single contiguous TextDelta that turns
oldTextintonewText, ornullwhen they are equal. -
defaultRichAttributeStyle(
Map< String, Object?> attributes) → TextStyle - The default RichAttributeStyle.
-
echoesRichText(
List< RichTextDelta> dropped, {required int deleted, required int inserted, int embedsInserted = 0, int embedsUpdated = 0, OwnsFormat? ownsFormat}) → bool -
Whether
droppedholds nothing but a rich text write ofdeletedandinsertedrunes. -
formatsWithin(
int from, int to, Map< String, Object?> attributes) → OwnsFormat -
An OwnsFormat for the formats a write puts on
[from, to): each key set to its value inattributes. -
mapOffsetThroughDelta(
int offset, TextDelta delta) → int -
Maps a caret/selection
offsetvalid in the text beforedeltato the equivalent offset in the text after it. -
resolveCrdtHandler<
H extends Handler> (BaseCRDTDocument document, String id) → H -
Returns the handler registered under
idondocument, cast toH. -
resolveDeltaProvider<
V, D extends ComposableDelta< (D> >BaseCRDTDocument document, String id, String widgetName) → DeltaProvider< V, D> -
Returns the handler registered under
idas aDeltaProvider<V, D>. -
resolveTextCursorLabelRect(
{required Size labelSize, required Rect caret, required Size bounds, required CrdtTextCursorLabelPlacement placement}) → Rect -
The rect of a cursor name tag of
labelSize, anchored tocaretinside a field ofbounds, followingplacement.
Typedefs
- CrdtAwarenessCursorWidgetBuilder = Widget Function(BuildContext context, CrdtAwarenessCursor cursor)
-
Builds the widget drawn at a remote collaborator's pointer, given its
presence
cursor. Used by CrdtAwarenessCursorsBuilder; the returned widget is positioned with its top-left at the pointer. -
CrdtDeltaCallback<
D> = void Function(BuildContext context, HandlerDelta< D> event) - Called with what one change did to the handler.
-
CrdtDeltaResetCallback<
V> = void Function(BuildContext context, DeltaSyncPoint< V> sync, ResetCause cause) - Called when the handler's value has to be adopted again from scratch.
-
CrdtDeltaWidgetBuilder<
V> = Widget Function(BuildContext context, V value) - Called with the current value of the handler.
-
CrdtDocumentSelector<
R> = R Function(BuildContext context, CRDTDocument document) -
Selects a value
Rfrom the ambientCRDTDocument. -
CrdtHandlerListenerCallback<
H extends Handler> = void Function(BuildContext context, H handler) - Side-effect callback invoked by CrdtHandlerListener on a handler change.
-
CrdtHandlerSelectorFn<
H extends Handler, R> = R Function(BuildContext context, H handler) -
Selects a value
Rfrom a handlerH. -
CrdtHandlerSelectorWidgetBuilder<
R> = Widget Function(BuildContext context, R value) - Builder invoked by CrdtHandlerSelector with the selected value.
-
CrdtHandlerWidgetBuilder<
H extends Handler> = Widget Function(BuildContext context, H handler) - Builder invoked by CrdtHandlerBuilder with the resolved handler.
- CrdtHistoryWidgetBuilder = Widget Function(BuildContext context, HistorySession session, Widget? child)
- Builder invoked by CrdtHistoryScope on every cursor move.
- CrdtLocalPointerCallback = void Function(Offset position, {required bool hovering})
-
Reports the local pointer, normalized into
[0, 1];hoveringis false when the pointer left the pane. -
CrdtSelectorWidgetBuilder<
R> = Widget Function(BuildContext context, R value) - Builder invoked by CrdtSelector with the selected value.
- CrdtWidgetBuilder = Widget Function(BuildContext context, CRDTDocument document)
- Builder invoked by CrdtBuilder on every document update.
- CreateCrdtDocument = CRDTDocument Function(BuildContext context)
-
Signature for the
createcallback of CrdtProvider. -
DeltaProviderResolver<
V, D extends ComposableDelta< D> > = DeltaProvider<V, D> Function(BaseCRDTDocument document, String id) -
Finds the handler registered under
idand checks it publishes the shape the caller asked for. -
OwnsFormat
= bool Function(int from, int to, Map<
String, Object?> attributes) -
Whether a format of
attributeson the runes[from, to)is part of a write. -
RichAttributeStyle
= TextStyle Function(Map<
String, Object?> attributes) - Maps the attributes of a run to the style it is painted with.
Exceptions / Errors
- ProviderNotFoundException
-
The error that will be thrown if
Provider.offails to find aProvideras an ancestor of the BuildContext used.