Selection extension type

A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or manipulation, call window.getSelection.

A user may make a selection from left to right (in document order) or right to left (reverse of document order). The anchor is where the user began the selection and the focus is where the user ends the selection. If you make a selection with a desktop mouse, the anchor is placed where you pressed the mouse button, and the focus is placed where you released the mouse button.

Note: Anchor and focus should not be confused with the start and end positions of a selection. The anchor can be placed before the focus or vice versa, depending on the direction you made your selection.

on
Implemented types
Available extensions

Properties

anchorNode Node?
no setter
anchorOffset int
no setter
direction String
no setter
focusNode Node?
no setter
focusOffset int
no setter
hashCode int
The hash code for this object.
no setterinherited
isCollapsed bool
no setter
isDefinedAndNotNull bool

Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension

no setter
isNull bool

Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension

Whether this value corresponds to JavaScript null.
no setter
isTruthy JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of !!this in JavaScript.
no setter
isUndefined bool

Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension

Whether this value corresponds to JavaScript undefined.
no setter
isUndefinedOrNull bool

Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension

no setter
not JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of !this in JavaScript.
no setter
rangeCount int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
no setter

Methods

add(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this + any in JavaScript.
addRange(Range range) → void
The Selection.addRange() method adds a Range to a Selection.
and(JSAny? any) JSAny?

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this && any in JavaScript.
callMethod<R extends JSAny?>(JSAny method, [JSAny? arg1, JSAny? arg2, JSAny? arg3, JSAny? arg4]) → R

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Calls method on this JSObject with up to four arguments.
callMethodVarArgs<R extends JSAny?>(JSAny method, [List<JSAny?>? arguments]) → R

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Calls method on this JSObject with a variable number of arguments.
collapse(Node? node, [int offset]) → void
The Selection.collapse() method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there.
collapseToEnd() → void
The Selection.collapseToEnd() method collapses the selection to the end of the last range in the selection. If the content of the selection is focused and editable, the caret will blink there.
collapseToStart() → void
The Selection.collapseToStart() method collapses the selection to the start of the first range in the selection. If the content of the selection is focused and editable, the caret will blink there.
containsNode(Node node, [bool allowPartialContainment]) bool
The Selection.containsNode() method indicates whether a specified node is part of the selection.
dartify() Object?

Available on JSAny?, provided by the JSAnyUtilityExtension extension

Converts a JavaScript value to the Dart equivalent if possible.
delete(JSAny property) JSBoolean

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Deletes the property with key property from this JSObject.
deleteFromDocument() → void
The deleteFromDocument() method of the Selection interface deletes the selected text from the document's DOM.
divide(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this / any in JavaScript.
empty() → void
The Selection.empty() method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal to null and nothing selected. When this method is called, a Document/selectionchange_event event is fired at the document.
equals(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this == any in JavaScript.
exponentiate(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this ** any in JavaScript.
extend(Node node, [int offset]) → void
The Selection.extend() method moves the focus of the selection to a specified point. The anchor of the selection does not move. The selection will be from the anchor to the new focus, regardless of direction.
getComposedRanges(ShadowRoot shadowRoots) JSArray<StaticRange>
getProperty<R extends JSAny?>(JSAny property) → R

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

The value of the property key property of this JSObject.
getRangeAt(int index) Range
The Selection.getRangeAt() method returns a range object representing one of the ranges currently selected.
greaterThan(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this > any in JavaScript.
greaterThanOrEqualTo(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this >= any in JavaScript.
has(String property) bool

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Shorthand helper for hasProperty to check whether this JSObject contains the property key property, but takes and returns a Dart value.
hasProperty(JSAny property) JSBoolean

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Whether or not this JSObject contains the property key property.
instanceof(JSFunction constructor) bool

Available on JSAny?, provided by the JSAnyUtilityExtension extension

Whether this JSAny? is an instanceof constructor.
instanceOfString(String constructorName) bool

Available on JSAny?, provided by the JSAnyUtilityExtension extension

Whether this JSAny? is an instanceof the constructor that is defined by constructorName, which is looked up in the globalContext.
isA<T extends JSAny?>() bool

Available on JSAny?, provided by the JSAnyUtilityExtension extension

Whether this JSAny? is an instance of the JavaScript type that is declared by T.
lessThan(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this < any in JavaScript.
lessThanOrEqualTo(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this <= any in JavaScript.
modify([String alter, String direction, String granularity]) → void
The Selection.modify() method applies a change to the current selection or cursor position, using simple textual commands.
modulo(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this % any in JavaScript.
multiply(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this * any in JavaScript.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notEquals(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this != any in JavaScript.
or(JSAny? any) JSAny?

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this || any in JavaScript.
removeAllRanges() → void
The Selection.removeAllRanges() method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal to null and nothing selected. When this method is called, a Document/selectionchange_event event is fired at the document.
removeRange(Range range) → void
The Selection.removeRange() method removes a range from a selection.
selectAllChildren(Node node) → void
The Selection.selectAllChildren() method adds all the children of the specified node to the selection. Previous selection is lost.
setBaseAndExtent(Node anchorNode, int anchorOffset, Node focusNode, int focusOffset) → void
The setBaseAndExtent() method of the Selection interface sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.
setPosition(Node? node, [int offset]) → void
The Selection.setPosition() method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there.
setProperty(JSAny property, JSAny? value) → void

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Write the value of property key property of this JSObject.
strictEquals(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this === any in JavaScript.
strictNotEquals(JSAny? any) JSBoolean

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this !== any in JavaScript.
subtract(JSAny? any) JSAny

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this - any in JavaScript.
toString() String
A string representation of this object.
inherited
typeofEquals(String typeString) bool

Available on JSAny?, provided by the JSAnyUtilityExtension extension

Whether the result of typeof on this JSAny? is typeString.
unsignedRightShift(JSAny? any) JSNumber

Available on JSAny?, provided by the JSAnyOperatorExtension extension

The result of this >>> any in JavaScript.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String property) JSAny?

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Shorthand helper for getProperty to get the value of the property key property of this JSObject, but takes and returns a Dart value.
operator []=(String property, JSAny? value) → void

Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension

Shorthand helper for setProperty to write the value of the property key property of this JSObject, but takes a Dart value.