HtmlElementView class Null safety
Embeds an HTML element in the Widget hierarchy in Flutter Web.
NOTE: This only works in Flutter Web. To embed web content on other
platforms, consider using the flutter_webview
plugin.
Embedding HTML is an expensive operation and should be avoided when a Flutter equivalent is possible.
The embedded HTML is painted just like any other Flutter widget and transformations apply to it as well. This widget should only be used in Flutter Web.
The widget fills all available space, the parent of this object must provide bounded layout constraints.
Due to security restrictions with cross-origin <iframe>
elements, Flutter
cannot dispatch pointer events to an HTML view. If an <iframe>
is the
target of an event, the window containing the <iframe>
is not notified
of the event. In particular, this means that any pointer events which land
on an <iframe>
will not be seen by Flutter, and so the HTML view cannot
participate in gesture detection with other widgets.
The way we enable accessibility on Flutter for web is to have a full-page button which waits for a double tap. Placing this full-page button in front of the scene would cause platform views not to receive pointer events. The tradeoff is that by placing the scene in front of the semantics placeholder will cause platform views to block pointer events from reaching the placeholder. This means that in order to enable accessibility, you must double tap the app outside of a platform view. As a consequence, a full-screen platform view will make it impossible to enable accessibility. Make sure that your HTML views are sized no larger than necessary, or you may cause difficulty for users trying to enable accessibility.
The platform view's lifetime is the same as the lifetime of the State object for this widget. When the State is disposed the platform view (and auxiliary resources) are lazily released (some resources are immediately released and some by platform garbage collector). A stateful widget's state is disposed when the widget is removed from the tree or when it is moved within the tree. If the stateful widget has a key and it's only moved relative to its siblings, or it has a GlobalKey and it's moved within the tree, it will not be disposed.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- HtmlElementView
Constructors
- HtmlElementView({Key? key, required String viewType, PlatformViewCreatedCallback? onPlatformViewCreated})
-
Creates a platform view for Flutter Web.
const
Properties
- hashCode → int
- The hash code for this object.
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onPlatformViewCreated → PlatformViewCreatedCallback?
-
Callback to invoke after the platform view has been created.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- viewType → String
-
The unique identifier for the HTML view type to be embedded by this widget.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.protected">@protectedinherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
nonVirtual">@nonVirtualinherited