tmpflutter_webview 0.9.7 tmpflutter_webview: ^0.9.7 copied to clipboard
A Flutter plogin that you can easilly develop for webview.
A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
Requirements #
- Dart sdk: ">=2.17.0 <4.0.0"
- Flutter: ">=3.0.0"
- Android:
minSdkVersion >= 19
,compileSdk >= 34
, AGP version>= 7.3.0
(use Android Studio - Android Gradle plugin Upgrade Assistant for help), support forandroidx
(see AndroidX Migration to migrate an existing app) - iOS 9.0+:
--ios-language swift
, Xcode version>= 14.3
- MacOS 10.11+: Xcode version
>= 14.3
WebView Page Instruction Code Sample #
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:tmpflutter_webview/tmpflutter_webview.dart';
class WebViewExampleScreen extends StatefulWidget {
@override
_WebViewExampleScreenState createState() => _WebViewExampleScreenState();
}
class _WebViewExampleScreenState extends State<WebViewExampleScreen> {
final GlobalKey webViewKey = GlobalKey();
InAppWebViewController? webViewController;
InAppWebViewSettings settings = InAppWebViewSettings(
isInspectable: kDebugMode,
mediaPlaybackRequiresUserGesture: false,
allowsInlineMediaPlayback: true,
iframeAllow: "camera; microphone",
iframeAllowFullscreen: true);
String url = "";
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(children: <Widget>[
Expanded(
child: Stack(
children: [
InAppWebView(
key: webViewKey,
mediaId: '560363030',
userParameter: 'user',
prefixUrl: 'https://dev.fusion-wall.smaad.net/wall/',
initialSettings: settings,
onWebViewCreated: (controller) async {
webViewController = controller;
},
onLoadStart: (controller, url) async {
setState(() {
this.url = url.toString();
});
},
onPermissionRequest: (controller, request) async {
return PermissionResponse(
resources: request.resources,
action: PermissionResponseAction.GRANT);
},
shouldOverrideUrlLoading: (controller, navigationAction) async {
var uri = navigationAction.request.url!;
print('uri = $uri');
return NavigationActionPolicy.ALLOW;
},
onLoadStop: (controller, url) async {
setState(() {
this.url = url.toString();
});
},
onReceivedError: (controller, request, error) {},
onWebViewClosed: (controller) async {
//TODO Navigator.pop(context);
print('webview closed');
Navigator.pop(context);
},
onUpdateVisitedHistory: (controller, url, isReload) {
setState(() {
this.url = url.toString();
});
},
onConsoleMessage: (controller, consoleMessage) {
print(consoleMessage);
},
),
],
),
),
])));
}
}
Installation #
Add tmpflutter_webview
as a dependency in your pubspec.yaml file.
Installation - Web support #
To make it work properly on the Web platform, you need to add the web_support.js
file inside the <head>
of your web/index.html
file:
<head>
<!-- ... -->
<script type="application/javascript" src="/assets/packages/tmpflutter_webview_web/assets/web/web_support.js" defer></script>
<!-- ... -->
</head>