UserScriptWebViewWrapperDelegate class
An implementation of WebViewWrapperDelegate that allows to inject required Contentsquare script in the WebView through user script.
This injection must be done through the UserScript like in the initialUserScripts
parameter of
InAppWebView
of the package flutter_inappwebview
.
Usage:
// Using the `InAppWebView` of `flutter_inappwebview`
ContentsquareWebViewWrapper(
delegate: UserScriptWebViewWrapperDelegate(
builder: (BuildContext context, String userScript) {
return InAppWebView(
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
// 1. Ensure JavaScript is enabled
javaScriptEnabled: true,
),
),
initialUrlRequest: URLRequest(
url: Uri.parse(url),
),
initialUserScripts: UnmodifiableListView([
UserScript(
// 2.a Initialized the delegate properly
// by setting the userScript as source
source: userScript,
// 2.b Initialized the delegate properly
// by setting the injectionTime as AT_DOCUMENT_START
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START,
),
]),
);
},
),
)
- Implemented types
Constructors
- UserScriptWebViewWrapperDelegate({required UserScriptWebViewWrapperBuilder builder})
-
Creates an instance of UserScriptWebViewWrapperDelegate used
to inject user script in the WebView.
const
Properties
- builder → UserScriptWebViewWrapperBuilder
-
Builder that will return the WebView where the user script
is injected.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
{required BuildContext context, required String userScriptSource}) → Widget -
Returns the WebView widget that needs to be wrapped.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited