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.
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.
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 ==).
CrdtProvider
Provides a CRDTDocument to its subtree
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 TextField bound to the same handler id).
CrdtTextFieldBuilder
Binds a TextEditingController to the text handler registered under id (CRDTTextHandler or CRDTFugueTextHandler), the way collaborative editor bindings (e.g. Yjs) do:
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 select method on BuildContext.
WatchContext on BuildContext
Exposes the watch method.

Functions

computeTextDelta(String oldText, String newText) TextDelta?
Computes the single contiguous TextDelta that turns oldText into newText, or null when they are equal.
mapOffsetThroughDelta(int offset, TextDelta delta) int
Maps a caret/selection offset valid in the text before delta to the equivalent offset in the text after it.
resolveCrdtHandler<H extends Handler>(CRDTDocument document, String id) → H
Returns the handler registered under id on document, cast to H.
resolveTextCursorLabelRect({required Size labelSize, required Rect caret, required Size bounds, required CrdtTextCursorLabelPlacement placement}) Rect
The rect of a cursor name tag of labelSize, anchored to caret inside a field of bounds, following placement.

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.
CrdtDocumentSelector<R> = R Function(BuildContext context, CRDTDocument document)
Selects a value R from the ambient CRDTDocument.
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 R from a handler H.
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.
CrdtLocalPointerCallback = void Function(Offset position, {required bool hovering})
Reports the local pointer, normalized into [0, 1]; hovering is 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 create callback of CrdtProvider.

Exceptions / Errors

ProviderNotFoundException
The error that will be thrown if Provider.of fails to find a Provider as an ancestor of the BuildContext used.