Skip to content

Instantly share code, notes, and snippets.

@diamantidis
Created October 17, 2021 17:29
Show Gist options
  • Save diamantidis/30a6fd1d5a1ba2c7f50b59781618141f to your computer and use it in GitHub Desktop.
Save diamantidis/30a6fd1d5a1ba2c7f50b59781618141f to your computer and use it in GitHub Desktop.
Flutter WebView
WebViewController? _webViewController;
Widget buildWebView() {
return WebView(
initialUrl: 'about:blank',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) async {
_webViewController = webViewController;
String fileContent = await rootBundle.loadString('assets/index.html');
_webViewController?.loadUrl(Uri.dataFromString(fileContent, mimeType: 'text/html', encoding: Encoding.getByName('utf-8')).toString());
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment