Skip to main content

WebView

The Stac WebView allows you to display WebView widget using JSON in your app. It is based on the webview_flutter plugin.

Usage​

  1. Add stac_webview as a dependency in your pubspec.yaml file.

Install the plugin by running the following command from the project root:

flutter pub add stac_webview

or add it manually in your pubspec.yaml file:

  dependencies:
stac_webview:
  1. Add StacWebViewParser in Stac initialize.
void main() async {
await Stac.initialize(
parsers: const [
StacWebViewParser(),
],
);

runApp(const MyApp());
}

Properties​

PropertyTypeDescription
urlStringThe URL to load in the WebView.
javaScriptModeJavaScriptModeSets whether JavaScript execution is enabled. Default is JavaScriptMode.unrestricted.
backgroundColorStringBackground color of the WebView. Default is #FFFFFF.
userAgentString?The user agent for the WebView.
enableZoomboolSets whether zoom is enabled for the WebView. Default is false.
layoutDirectionTextDirectionThe layout direction for the WebView. Default is TextDirection.ltr.

Example JSON​

{
"type": "webView",
"url": "https://github.com/StacDev/stac"
}