Document class abstract
A read-only document with styled text and multimedia elements.
A Document is comprised of a list of DocumentNodes, which describe the type and substance of a piece of content within the document. For example, a ParagraphNode holds a single paragraph of text within the document.
New types of content can be added by subclassing DocumentNode.
To represent a specific location within a Document, see DocumentPosition.
A Document has no opinion on the visual presentation of its content.
To edit the content of a document, see DocumentEditor.
- Implemented types
- Implementers
- Available extensions
Constructors
- Document()
Properties
- first → DocumentNode
-
The first element.
no setterinherited
- firstOrNull → DocumentNode?
-
Returns the first DocumentNode in this Document, or
nullif this Document is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns
trueif this Document has zero nodes, orfalseif it has `1+ nodes.no setteroverride - isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
DocumentNode> -
A new
Iteratorthat allows iterating the elements of thisIterable.no setterinherited - last → DocumentNode
-
The last element.
no setterinherited
- lastOrNull → DocumentNode?
-
Returns the last DocumentNode in this Document, or
nullif this Document is empty.no setter - length → int
-
The number of elements in this Iterable.
no setterinherited
- nodeCount → int
-
The number of DocumentNodes in this Document.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → DocumentNode
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
addListener(
DocumentChangeListener listener) → void -
any(
bool test(DocumentNode element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
Rinstances.inherited -
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element.inherited -
doesSelectedTextContainAttributions(
DocumentSelection selection, Set< Attribution> attributions) → bool -
Available on Document, provided by the DocumentSelectionWithText extension
Returnstrueif all the text within the givenselectioncontains at least some characters with each of the givenattributions. -
doesSelectionContainPosition(
DocumentSelection selection, DocumentPosition position) → bool -
Available on Document, provided by the InspectDocumentSelection extension
Returnstrueif, and only if, the givenpositionsits within the givenselectionin thisDocument. -
elementAt(
int index) → DocumentNode -
Returns the
indexth element.inherited -
every(
bool test(DocumentNode element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> toElements(DocumentNode element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(DocumentNode element), {DocumentNode orElse()?}) → DocumentNode -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, DocumentNode element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< DocumentNode> other) → Iterable<DocumentNode> -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void action(DocumentNode element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
getAffinityBetween(
{required DocumentPosition base, required DocumentPosition extent}) → TextAffinity -
Available on Document, provided by the InspectDocumentAffinity extension
Returns the affinity direction implied by the givenbaseandextent. -
getAffinityBetweenNodes(
DocumentNode base, DocumentNode extent) → TextAffinity -
Available on Document, provided by the InspectDocumentAffinity extension
-
getAffinityForRange(
DocumentRange range) → TextAffinity -
Available on Document, provided by the InspectDocumentAffinity extension
-
getAffinityForSelection(
DocumentSelection selection) → TextAffinity -
Available on Document, provided by the InspectDocumentAffinity extension
-
getAllAttributions(
DocumentSelection selection) → Set< Attribution> -
Available on Document, provided by the DocumentSelectionWithText extension
Returns all attributions that appear throughout the entirety of the selected range. -
getAttributionsByType<
T> (DocumentSelection selection) → Set< T> -
Available on Document, provided by the DocumentSelectionWithText extension
Returns all attributions of typeTthat appear throughout the entirety of the selected range. -
getNode(
DocumentPosition position) → DocumentNode? -
Returns the DocumentNode at the given
position, ornullif no such node exists in this Document. -
getNodeAfter(
DocumentNode node) → DocumentNode? -
Returns the DocumentNode that appears immediately after the
given
nodein this Document, or null if the givennodeis the last node, or the givennodedoes not exist in this Document. -
getNodeAfterById(
String nodeId) → DocumentNode? -
Returns the DocumentNode that appears immediately after the
node with the given
nodeIdin this Document, ornullif the matching node is the last node in the document, or no such node exists. -
getNodeAt(
int index) → DocumentNode? -
Returns the DocumentNode at the given
index, ornullif no such node exists. -
getNodeBefore(
DocumentNode node) → DocumentNode? -
Returns the DocumentNode that appears immediately before the
given
nodein this Document, or null if the givennodeis the first node, or the givennodedoes not exist in this Document. -
getNodeBeforeById(
String nodeId) → DocumentNode? -
Returns the DocumentNode that appears immediately before the
node with the given
nodeIdin this Document, ornullif the matching node is the first node in the document, or no such node exists. -
getNodeById(
String nodeId) → DocumentNode? -
Returns the DocumentNode with the given
nodeId, ornullif no such node exists. -
getNodeIndex(
DocumentNode node) → int -
Returns the index of the given
node, or-1if thenodedoes not exist within this Document. -
getNodeIndexById(
String nodeId) → int -
Returns the index of the
DocumentNodein thisDocumentthat has the givennodeId, or-1if the node does not exist. -
getNodesInContentOrder(
DocumentSelection selection) → List< DocumentNode> -
Available on Document, provided by the InspectDocumentSelection extension
Returns a list of all theDocumentNodeswithin the givenselection, ordered from upstream to downstream. -
getNodesInside(
DocumentPosition position1, DocumentPosition position2) → List< DocumentNode> -
Returns all DocumentNodes from
position1toposition2, including the nodes atposition1andposition2. -
getRangeBetween(
DocumentPosition position1, DocumentPosition position2) → DocumentRange -
Available on Document, provided by the InspectDocumentRange extension
Returns a DocumentRange that ranges fromposition1toposition2, includingposition1andposition2. -
hasEquivalentContent(
Document other) → bool -
Returns
trueif the content in theotherdocument is equivalent to the content in this document, ignoring any details that are unrelated to content, such as individual node IDs. -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(DocumentNode element), {DocumentNode orElse()?}) → DocumentNode -
The last element that satisfies the given predicate
test.inherited -
map<
T> (T toElement(DocumentNode e)) → Iterable< T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reduce(
DocumentNode combine(DocumentNode value, DocumentNode element)) → DocumentNode -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
removeListener(
DocumentChangeListener listener) → void -
selectDownstreamPosition(
DocumentPosition docPosition1, DocumentPosition docPosition2) → DocumentPosition -
Available on Document, provided by the InspectDocumentSelection extension
GivendocPosition1anddocPosition2, returns theDocumentPositionthat appears last in the document. -
selectUpstreamPosition(
DocumentPosition docPosition1, DocumentPosition docPosition2) → DocumentPosition -
Available on Document, provided by the InspectDocumentSelection extension
GivendocPosition1anddocPosition2, returns theDocumentPositionthat appears first in the document. -
singleWhere(
bool test(DocumentNode element), {DocumentNode orElse()?}) → DocumentNode -
The single element that satisfies
test.inherited -
skip(
int count) → Iterable< DocumentNode> -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(DocumentNode value)) → Iterable< DocumentNode> -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
take(
int count) → Iterable< DocumentNode> -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(DocumentNode value)) → Iterable< DocumentNode> -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toHtml(
{DocumentSelection? selection, NodeHtmlSerializerChain nodeSerializers = defaultNodeHtmlSerializerChain, InlineHtmlSerializerChain inlineSerializers = defaultInlineHtmlSerializers, bool skipUnknownNodes = true}) → String -
Available on Document, provided by the HtmlSerialization extension
Converts this Document to an HTML representation. -
toList(
{bool growable = true}) → List< DocumentNode> -
Creates a List containing the elements of this Iterable.
inherited
-
toPlainText(
{DocumentSelection? selection}) → String -
Available on Document, provided by the ToPlainText extension
Serializes this Document to a plain-text representation by writing the text from every TextNode to aString. -
toSet(
) → Set< DocumentNode> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
where(
bool test(DocumentNode element)) → Iterable< DocumentNode> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited