dart:html library
HTML elements and other resources for web-based applications that need tointeract with the browser and the DOM (Document Object Model).
Note
This core library is deprecated, and scheduled for removal in late 2025.It has been replaced bypackage:web.Themigration guide has more details.
This library includes DOM element types, CSS styling, local storage,media, speech, events, and more.To get started,check out theElement class, the base class for many of the HTMLDOM types.
For information on writing web apps with Dart, seehttps://dart.dev/web.
Classes
- AbortPaymentEvent
- AbsoluteOrientationSensor
- AbstractWorker
- Accelerometer
- AccessibleNode
- AccessibleNodeList
- AmbientLightSensor
- AnchorElement
- Animation
- AnimationEffectReadOnly
- AnimationEffectTiming
- AnimationEffectTimingReadOnly
- AnimationEvent
- AnimationPlaybackEvent
- AnimationTimeline
- AnimationWorkletGlobalScope
- ApplicationCache
- ApplicationCache is accessed viaWindow.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 extendsEvent> - A stream of custom events, which enables the user to "fire" (add) their owncustom 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 alength measurementin 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 extendsElement> - An immutable list containing HTML elements. This list contains someadditional methods when compared to regular lists for ease of CSSmanipulation on a group of elements.
- ElementStream<
T extendsEvent> - A specialized Stream available toElements 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 extendsEvent> - 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 formsubmit 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 astream of outgoing KeyEvents with cross-browser consistent keyCode andcharCode values despite the fact that a multitude of browsers that havevarying keyboard default behavior.
- KeyCode
- Defines the keycode values for keys that are returned byKeyboardEvent.keyCode.
- KeyEvent
- A custom KeyboardEvent that attempts to eliminate cross-browserinconsistencies, and also provide both keyCode and charCode informationfor all key events (when such information can be determined).
- KeyframeEffect
- KeyframeEffectReadOnly
- KeyLocation
- Defines the standard key locations returned byKeyboardEvent.getKeyLocation.
- LabelElement
- LegendElement
- LIElement
- LinearAccelerationSensor
- LinkElement
- LocalDateTimeInputElement
- A date and time (year, month, day, hour, minute, second, fraction of asecond) with no time zone.
- Location
- LocationBase
- Magnetometer
- MapElement
- MathMLElement
- 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
- MenuElement
- 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
- NavigationPreloadManager
- Navigator
- NavigatorAutomationInformation
- NavigatorConcurrentHardware
- NavigatorCookies
- NavigatorID
- NavigatorLanguage
- NavigatorOnLine
- NavigatorUserMediaError
- NetworkInformation
- Node
- NodeFilter
- NodeIterator
- NodeList
- NodeTreeSanitizer
- Performs sanitization of a node tree after construction to ensure that itdoes not contain any disallowed elements or attributes.
- NodeValidator
- Interface used to validate that only accepted elements and attributes areallowed 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 extendsnum> - 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 otherRadioButtonInputElement controlsforms a radio button group in which only one control can be checked at atime.
- Range
- RangeInputElement
- Similar toNumberInputElement but the browser may provide more optimalstyling (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 extendsnum> - A class for representing two-dimensional rectangles whose properties areimmutable.
- 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 toTextInputElement, but on platforms where search is styleddifferently 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 theWindow.localStorage andWindow.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 particularattribute 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.no setter
- window→Window
- Top-level container for a web page, which is usually a browser tab or window.no setter
Functions
- promiseToFuture<
T> (ObjectjsPromise)→Future< T> - Converts a JavaScript Promise to a DartFuture.
- promiseToFutureAsMap(
dynamicjsPromise)→Future< Map< String,dynamic> ?> - Convert a JS Promise to a Future<Map<String, dynamic>>.
- querySelector(
Stringselectors)→Element? - Finds the first descendant element of this document that matches thespecified group of selectors.
- querySelectorAll<
T extendsElement> (Stringselectors)→ElementList< T> - Finds all descendant elements of this document that match the specifiedgroup of selectors.
Typedefs
- BlobCallback= void Function(Blob?blob)
- CustomElementConstructor= void Function()
- DecodeErrorCallback= void Function(DomExceptionerror)
- DecodeSuccessCallback= void Function(AudioBufferdecodedData)
- EventListener= dynamic Function(Eventevent)
- FontFaceSetForEachCallback= void Function(FontFacefontFace,FontFacefontFaceAgain,FontFaceSetset)
- Emitted for any setlike IDL entry needs a callback signature.Today there is only one.
- FrameRequestCallback= void Function(numhighResTime)
- FunctionStringCallback= void Function(Stringdata)
- IdleRequestCallback= void Function(IdleDeadlinedeadline)
- IntersectionObserverCallback= void Function(Listentries,IntersectionObserverobserver)
- MediaSessionActionHandler= void Function()
- MessageCallback= void Function(Mapmessage)
- MetadataCallback= void Function(Metadatametadata)
- MojoWatchCallback= void Function(intresult)
- MutationCallback= void Function(Listmutations,MutationObserverobserver)
- PerformanceObserverCallback= void Function(PerformanceObserverEntryListentries,PerformanceObserverobserver)
- RemotePlaybackAvailabilityCallback= void Function(boolavailable)
- ReportingObserverCallback= void Function(Listreports,ReportingObserverobserver)
- RequestAnimationFrameCallback= void Function(numhighResTime)
- ResizeObserverCallback= void Function(Listentries,ResizeObserverobserver)
- RtcPeerConnectionErrorCallback= void Function(DomExceptionexception)
- RtcStatsCallback= void Function(RtcStatsResponseresponse)
- ScrollStateCallback= void Function(ScrollStatescrollState)
- StorageErrorCallback= void Function(DomErrorerror)
- StorageQuotaCallback= void Function(intgrantedQuotaInBytes)
- StorageUsageCallback= void Function(intcurrentUsageInBytes,intcurrentQuotaInBytes)
- TimeoutHandler= void Function()
- VoidCallback= void Function()