dart:html library Null safety

HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model).

This library includes DOM element types, CSS styling, local storage, media, speech, events, and more. To get started, check out the Element class, the base class for many of the HTML DOM types.

For information on writing web apps with Dart, see https://dart.dev/web.

Classes

AbortPaymentEvent
AbsoluteOrientationSensor
AbstractWorker
Accelerometer
AccessibleNode
AccessibleNodeList
AmbientLightSensor
AnchorElement
Animation
AnimationEffectReadOnly
AnimationEffectTiming
AnimationEffectTimingReadOnly
AnimationEvent
AnimationPlaybackEvent
AnimationTimeline
AnimationWorkletGlobalScope
ApplicationCache
ApplicationCache is accessed via Window.applicationCache.
ApplicationCacheErrorEvent
AreaElement
DOM Area Element, which links regions of an image map with a hyperlink. [...]
AudioElement
AuthenticatorAssertionResponse
AuthenticatorAttestationResponse
AuthenticatorResponse
BackgroundFetchClickEvent
BackgroundFetchedEvent
BackgroundFetchEvent
BackgroundFetchFailEvent
BackgroundFetchFetch
BackgroundFetchManager
BackgroundFetchRegistration
BackgroundFetchSettledFetch
BarcodeDetector
BarProp
BaseElement
BatteryManager
BeforeInstallPromptEvent
BeforeUnloadEvent
Blob
BlobEvent
BluetoothRemoteGattDescriptor
Body
BodyElement
BRElement
BroadcastChannel
BudgetState
ButtonElement
ButtonInputElement
A button, with no default behavior.
CacheStorage
CanMakePaymentEvent
CanvasCaptureMediaStreamTrack
CanvasElement
CanvasGradient
An opaque canvas object representing a gradient. [...]
CanvasImageSource
An object that can be drawn to a 2D canvas rendering context. [...]
CanvasPattern
An opaque object representing a pattern of image, canvas, or video. [...]
CanvasRenderingContext
CanvasRenderingContext2D
CDataSection
CharacterData
CheckboxInputElement
A boolean editor control. [...]
ChildNode
Client
Clients
ClipboardEvent
CloseEvent
Comment
CompositionEvent
Console
ContentElement
CookieStore
Coordinates
Credential
CredentialsContainer
CredentialUserData
Crypto
CryptoKey
Css
CssCharsetRule
CssClassSet
A Set that stores the CSS class names for an element.
CssConditionRule
CssFontFaceRule
CssGroupingRule
CssImageValue
CssImportRule
CssKeyframeRule
CssKeyframesRule
CssKeywordValue
CssMatrixComponent
CssMediaRule
CssNamespaceRule
CssNumericValue
CssPageRule
CssPerspective
CssPositionValue
CssRect
A class for representing CSS dimensions. [...]
CssResourceValue
CssRotation
CssRule
CssScale
CssSkew
CssStyleDeclaration
CssStyleDeclarationBase
CssStyleRule
CssStyleSheet
CssStyleValue
CssSupportsRule
CssTransformComponent
CssTransformValue
CssTranslation
CssUnitValue
CssUnparsedValue
CssurlImageValue
CssVariableReferenceValue
CssViewportRule
CustomElementRegistry
CustomEvent
CustomStream<T extends Event>
A stream of custom events, which enables the user to "fire" (add) their own custom events to a stream.
DataElement
DataListElement
DataTransfer
DataTransferItem
DataTransferItemList
DateInputElement
A date (year, month, day) with no time zone. [...]
DedicatedWorkerGlobalScope
DeprecatedStorageInfo
DeprecatedStorageQuota
DeprecationReport
DetailsElement
DetectedBarcode
DetectedFace
DetectedText
DeviceAcceleration
DeviceMotionEvent
DeviceOrientationEvent
DeviceRotationRate
DialogElement
Dimension
Class representing a length measurement in CSS.
DirectoryEntry
DirectoryReader
DivElement
A generic container for content on an HTML page; corresponds to the <div> tag. [...]
DListElement
Document
The base class for all documents. [...]
DocumentFragment
DocumentOrShadowRoot
DocumentTimeline
DomError
DomException
DomImplementation
DomIterator
DomMatrix
DomMatrixReadOnly
DomParser
DomPoint
DomPointReadOnly
DomQuad
DomRectList
DomRectReadOnly
DomStringList
DomStringMap
DomTokenList
Element
An abstract class, which all HTML elements extend.
ElementEvents
ElementList<T extends Element>
An immutable list containing HTML elements. This list contains some additional methods when compared to regular lists for ease of CSS manipulation on a group of elements.
ElementStream<T extends Event>
A specialized Stream available to Elements to enable event delegation.
ElementUpgrader
A utility for changing the Dart wrapper type for elements.
EmailInputElement
An e-mail address or list of e-mail addresses. [...]
EmbedElement
Entry
ErrorEvent
Event
Events
Base class that supports listening for and dispatching browser events. [...]
EventSource
EventStreamProvider<T extends Event>
A factory to expose DOM events as Streams.
EventTarget
Base class for all browser objects that support events. [...]
ExtendableEvent
ExtendableMessageEvent
External
FaceDetector
FederatedCredential
FetchEvent
FieldSetElement
File
FileEntry
FileList
FileReader
FileSystem
FileUploadInputElement
A control for picking files from the user's computer.
FileWriter
FixedSizeListIterator<T>
FocusEvent
FontFace
FontFaceSet
FontFaceSetLoadEvent
FontFaceSource
ForeignFetchEvent
FormData
FormElement
Gamepad
GamepadButton
GamepadEvent
GamepadPose
Geolocation
Geoposition
GlobalEventHandlers
Gyroscope
HashChangeEvent
HeadElement
Headers
HeadingElement
HiddenInputElement
Hidden input which is not intended to be seen or edited by the user.
History
HistoryBase
HRElement
An <hr> tag.
HtmlCollection
HtmlDocument
HtmlElement
HtmlFormControlsCollection
HtmlHtmlElement
HtmlHyperlinkElementUtils
HtmlOptionsCollection
HttpRequest
A client-side XHR request for getting data from a URL, formally known as XMLHttpRequest. [...]
HttpRequestEventTarget
HttpRequestUpload
HttpStatus
HTTP status codes. Exported in dart:io and dart:html.
IdleDeadline
IFrameElement
ImageBitmap
ImageBitmapRenderingContext
ImageButtonInputElement
Either an image which the user can select a coordinate to or a form submit button.
ImageCapture
ImageData
ImageElement
ImmutableListMixin<E>
InputDeviceCapabilities
InputElement
InputElementBase
Exposes the functionality common between all InputElement types.
InstallEvent
IntersectionObserver
IntersectionObserverEntry
InterventionReport
KeyboardEvent
An event that describes user interaction with the keyboard. [...]
KeyboardEventStream
Records KeyboardEvents that occur on a particular element, and provides a stream of outgoing KeyEvents with cross-browser consistent keyCode and charCode values despite the fact that a multitude of browsers that have varying keyboard default behavior. [...]
KeyCode
Defines the keycode values for keys that are returned by KeyboardEvent.keyCode. [...]
KeyEvent
A custom KeyboardEvent that attempts to eliminate cross-browser inconsistencies, and also provide both keyCode and charCode information for all key events (when such information can be determined). [...]
KeyframeEffect
KeyframeEffectReadOnly
KeyLocation
Defines the standard key locations returned by KeyboardEvent.getKeyLocation.
LabelElement
LegendElement
LIElement
LinearAccelerationSensor
LinkElement
LocalDateTimeInputElement
A date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone. [...]
Location
LocationBase
Magnetometer
MapElement
MediaCapabilities
MediaCapabilitiesInfo
MediaDeviceInfo
MediaDevices
MediaElement
MediaEncryptedEvent
MediaError
MediaKeyMessageEvent
MediaKeys
MediaKeySession
MediaKeysPolicy
MediaKeyStatusMap
MediaKeySystemAccess
MediaList
MediaMetadata
MediaQueryList
MediaQueryListEvent
MediaRecorder
MediaSession
MediaSettingsRange
MediaSource
MediaStream
MediaStreamEvent
MediaStreamTrack
MediaStreamTrackEvent
MemoryInfo
An HTML [...]
MessageChannel
MessageEvent
MessagePort
Metadata
MetaElement
MeterElement
MidiAccess
MidiConnectionEvent
MidiInput
MidiInputMap
MidiMessageEvent
MidiOutput
MidiOutputMap
MidiPort
MimeType
MimeTypeArray
ModElement
MonthInputElement
A date consisting of a year and a month with no time zone. [...]
MouseEvent
MutationEvent
MutationObserver
MutationRecord
NetworkInformation
Node
NodeFilter
NodeIterator
NodeList
NodeTreeSanitizer
Performs sanitization of a node tree after construction to ensure that it does not contain any disallowed elements or attributes. [...]
NodeValidator
Interface used to validate that only accepted elements and attributes are allowed while parsing HTML strings into DOM nodes. [...]
NodeValidatorBuilder
Class which helps construct standard node validation policies. [...]
NoncedElement
NonDocumentTypeChildNode
NonElementParentNode
Notification
NotificationEvent
NumberInputElement
A numeric editor control.
ObjectElement
OffscreenCanvas
OffscreenCanvasRenderingContext2D
OListElement
OptGroupElement
OptionElement
OrientationSensor
OutputElement
OverconstrainedError
PageTransitionEvent
PaintRenderingContext2D
PaintSize
PaintWorkletGlobalScope
ParagraphElement
ParamElement
ParentNode
PasswordCredential
PasswordInputElement
Text with no line breaks (sensitive information).
Path2D
PaymentAddress
PaymentInstruments
PaymentManager
PaymentRequest
PaymentRequestEvent
PaymentRequestUpdateEvent
PaymentResponse
Performance
PerformanceEntry
PerformanceLongTaskTiming
PerformanceMark
PerformanceMeasure
PerformanceNavigation
PerformanceNavigationTiming
PerformanceObserver
PerformanceObserverEntryList
PerformancePaintTiming
PerformanceResourceTiming
PerformanceServerTiming
PerformanceTiming
Permissions
PermissionStatus
PhotoCapabilities
PictureElement
Platform
Plugin
PluginArray
Point<T extends num>
A utility class for representing two-dimensional positions. [...]
PointerEvent
PopStateEvent
PositionError
PreElement
Presentation
PresentationAvailability
PresentationConnection
PresentationConnectionAvailableEvent
PresentationConnectionCloseEvent
PresentationConnectionList
PresentationReceiver
PresentationRequest
ProcessingInstruction
ProgressElement
ProgressEvent
PromiseRejectionEvent
PublicKeyCredential
PushEvent
PushManager
PushMessageData
PushSubscription
PushSubscriptionOptions
QuoteElement
RadioButtonInputElement
A control that when used with other RadioButtonInputElement controls forms a radio button group in which only one control can be checked at a time. [...]
Range
RangeInputElement
Similar to NumberInputElement but the browser may provide more optimal styling (such as a slider control). [...]
RangeInputElementBase
Base interface for all input element types which involve ranges.
ReadyState
Contains the set of standard values returned by HTMLDocument.getReadyState.
Rectangle<T extends num>
A class for representing two-dimensional rectangles whose properties are immutable.
RelatedApplication
RelativeOrientationSensor
RemotePlayback
ReportBody
ReportingObserver
ResetButtonInputElement
A button, which when clicked, resets the form.
ResizeObserver
ResizeObserverEntry
RtcCertificate
RtcDataChannel
RtcDataChannelEvent
RtcDtmfSender
RtcDtmfToneChangeEvent
RtcIceCandidate
RtcLegacyStatsReport
RtcPeerConnection
RtcPeerConnectionIceEvent
RtcRtpContributingSource
RtcRtpReceiver
RtcRtpSender
RtcSessionDescription
RtcStatsReport
RtcStatsResponse
RtcTrackEvent
Screen
ScreenOrientation
ScriptElement
ScrollAlignment
Options for Element.scrollIntoView.
ScrollState
ScrollTimeline
SearchInputElement
Similar to TextInputElement, but on platforms where search is styled differently this will get the search style. [...]
SecurityPolicyViolationEvent
SelectElement
Selection
Sensor
SensorErrorEvent
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
ShadowElement
ShadowRoot
SharedArrayBuffer
SharedWorker
SharedWorkerGlobalScope
SlotElement
SourceBuffer
SourceBufferList
SourceElement
SpanElement
SpeechGrammar
SpeechGrammarList
SpeechRecognition
SpeechRecognitionAlternative
SpeechRecognitionError
SpeechRecognitionEvent
SpeechRecognitionResult
SpeechSynthesis
SpeechSynthesisEvent
SpeechSynthesisUtterance
SpeechSynthesisVoice
StaticRange
Storage
The type used by the Window.localStorage and Window.sessionStorage properties. Storage is implemented as a Map<String, String>. [...]
StorageEvent
StorageManager
StyleElement
StyleMedia
StylePropertyMap
StylePropertyMapReadonly
StyleSheet
SubmitButtonInputElement
A button, which when clicked, submits the form.
SyncEvent
SyncManager
TableCaptionElement
TableCellElement
TableColElement
TableElement
TableRowElement
TableSectionElement
TaskAttributionTiming
TelephoneInputElement
Represents a control for editing a telephone number. [...]
TemplateElement
Text
TextAreaElement
TextDetector
TextEvent
TextInputElement
A basic text input editor control.
TextInputElementBase
Base interface for all inputs which involve text editing.
TextMetrics
TextTrack
TextTrackCue
TextTrackCueList
TextTrackList
TimeElement
TimeInputElement
A time (hour, minute, seconds, fractional seconds) with no time zone. [...]
TimeRanges
TitleElement
Touch
TouchEvent
TouchList
TrackDefault
TrackDefaultList
TrackElement
TrackEvent
TransitionEvent
TreeWalker
TrustedHtml
TrustedScriptUrl
TrustedUrl
UIEvent
UListElement
UnderlyingSourceBase
UnknownElement
UriPolicy
Defines the policy for what types of uris are allowed for particular attribute values. [...]
Url
UrlInputElement
A control for editing an absolute URL. [...]
UrlSearchParams
UrlUtilsReadOnly
ValidityState
VideoElement
VideoPlaybackQuality
VideoTrack
VideoTrackList
VisualViewport
VR
VRCoordinateSystem
VRDevice
VRDeviceEvent
VRDisplay
VRDisplayCapabilities
VRDisplayEvent
VREyeParameters
VRFrameData
VRFrameOfReference
VRPose
VRSession
VRSessionEvent
VRStageBounds
VRStageBoundsPoint
VRStageParameters
VttCue
VttRegion
WebSocket
Use the WebSocket interface to connect to a WebSocket, and to send and receive data on that WebSocket. [...]
WeekInputElement
A date consisting of a week-year number and a week number with no time zone. [...]
WheelEvent
Window
Top-level container for the current browser tab or window. [...]
WindowBase
Top-level container for a browser tab or window. [...]
WindowBase64
WindowClient
WindowEventHandlers
Worker
WorkerGlobalScope
WorkerPerformance
WorkletAnimation
WorkletGlobalScope
XmlDocument
XmlSerializer
XPathEvaluator
XPathExpression
XPathNSResolver
XPathResult
XsltProcessor

Properties

document → HtmlDocument
Root node for all content in a web page.
read-only
window → Window
Top-level container for a web page, which is usually a browser tab or window. [...]
read-only

Functions

promiseToFuture<T>(Object jsPromise) → Future<T>
Converts a JavaScript Promise to a Dart Future. [...]
promiseToFutureAsMap(dynamic jsPromise) → Future<Map<String, dynamic>?>
Convert a JS Promise to a Future<Map<String, dynamic>>. [...]
querySelector(String selectors) → Element?
Finds the first descendant element of this document that matches the specified group of selectors. [...]
querySelectorAll<T extends Element>(String selectors) → ElementList<T>
Finds all descendant elements of this document that match the specified group of selectors. [...]

Typedefs

BlobCallback = void Function(Blob? blob)
CustomElementConstructor = void Function()
DecodeErrorCallback = void Function(DomException error)
DecodeSuccessCallback = void Function(AudioBuffer decodedData)
EventListener = dynamic Function(Event event)
FontFaceSetForEachCallback = void Function(FontFace fontFace, FontFace fontFaceAgain, FontFaceSet set)
Emitted for any setlike IDL entry needs a callback signature. Today there is only one.
FrameRequestCallback = void Function(num highResTime)
FunctionStringCallback = void Function(String data)
IdleRequestCallback = void Function(IdleDeadline deadline)
IntersectionObserverCallback = void Function(List entries, IntersectionObserver observer)
MediaSessionActionHandler = void Function()
MessageCallback = void Function(Map message)
MetadataCallback = void Function(Metadata metadata)
MojoWatchCallback = void Function(int result)
MutationCallback = void Function(List mutations, MutationObserver observer)
PerformanceObserverCallback = void Function(PerformanceObserverEntryList entries, PerformanceObserver observer)
RemotePlaybackAvailabilityCallback = void Function(bool available)
ReportingObserverCallback = void Function(List reports, ReportingObserver observer)
RequestAnimationFrameCallback = void Function(num highResTime)
ResizeObserverCallback = void Function(List entries, ResizeObserver observer)
RtcPeerConnectionErrorCallback = void Function(DomException exception)
RtcStatsCallback = void Function(RtcStatsResponse response)
ScrollStateCallback = void Function(ScrollState scrollState)
StorageErrorCallback = void Function(DomError error)
StorageQuotaCallback = void Function(int grantedQuotaInBytes)
StorageUsageCallback = void Function(int currentUsageInBytes, int currentQuotaInBytes)
TimeoutHandler = void Function()
VoidCallback = void Function()