ContentWorld class

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 and because the code runs inside an <iframe>;
  • also, the execution of the inline <script> could be blocked by the Content-Security-Policy header.

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


hashCode int
The hash code for this object.
no setterinherited
name String
The name of a custom content world. It cannot contain space characters.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toJson() Map<String, dynamic>
toMap() Map<String, dynamic>
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.

Static Properties

The default world for clients.
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.