ContentWorld class Null safety

Class that represents an object that defines a scope of execution for JavaScript code and which you use to prevent conflicts between different scripts.

NOTE for iOS: available on iOS 14.0+. This class represents the native WKContentWorld class.

NOTE for Android: it will create and append an <iframe> HTML element with id attribute equals to flutter_inappwebview_[name] to the webpage's content that contains only the inline <script> HTML elements in order to define a new scope of execution for JavaScript code. Unfortunately, there isn't any other way to do it. There are some limitations:

  • for any ContentWorld, except ContentWorld.PAGE (that is the webpage itself), if you need to access to the window or document global Object, you need to use window.top and window.top.document because the code runs inside an <iframe>;
  • also, the execution of the inline <script> could be blocked by the Content-Security-Policy header.

Constructors

ContentWorld.world({required String name})
Returns the custom content world with the specified name.

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
name String
The name of a custom content world. It cannot contain space characters.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toJson() Map<String, dynamic>
toMap() Map<String, dynamic>
toString() String
A string representation of this object. [...]
override

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Properties

DEFAULT_CLIENT ContentWorld
The default world for clients.
final
PAGE ContentWorld
The content world for the current webpage’s content. This property contains the content world for scripts that the current webpage executes. Be careful when manipulating variables in this content world. If you modify a variable with the same name as one the webpage uses, you may unintentionally disrupt the normal operation of that page.
final