updated example

This commit is contained in:
Lorenzo Pichilli 2022-10-11 10:10:13 +02:00
parent abab589d80
commit 310cd60a6e
6 changed files with 54 additions and 47 deletions

View File

@ -42,7 +42,7 @@ class _HeadlessInAppWebViewExampleScreenState
this.url = url.toString(); this.url = url.toString();
}); });
}, },
onUpdateVisitedHistory: (controller, url, androidIsReload) { onUpdateVisitedHistory: (controller, url, isReload) {
setState(() { setState(() {
this.url = url.toString(); this.url = url.toString();
}); });

View File

@ -102,6 +102,10 @@ class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
urlRequest: urlRequest:
URLRequest(url: Uri.parse("https://flutter.dev")), URLRequest(url: Uri.parse("https://flutter.dev")),
settings: InAppBrowserClassSettings( settings: InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings(
toolbarTopBackgroundColor: Colors.blue,
presentationStyle: ModalPresentationStyle.POPOVER
),
webViewSettings: InAppWebViewSettings( webViewSettings: InAppWebViewSettings(
useShouldOverrideUrlLoading: true, useShouldOverrideUrlLoading: true,
useOnLoadResource: true, useOnLoadResource: true,

View File

@ -19,7 +19,6 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
InAppWebViewSettings settings = InAppWebViewSettings( InAppWebViewSettings settings = InAppWebViewSettings(
useShouldOverrideUrlLoading: true, useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false, mediaPlaybackRequiresUserGesture: false,
isFindInteractionEnabled: false,
allowsInlineMediaPlayback: true, allowsInlineMediaPlayback: true,
iframeAllow: "camera; microphone", iframeAllow: "camera; microphone",
iframeAllowFullscreen: true iframeAllowFullscreen: true
@ -116,7 +115,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
InAppWebView( InAppWebView(
key: webViewKey, key: webViewKey,
initialUrlRequest: initialUrlRequest:
URLRequest(url: Uri.parse('https://github.com/flutter')), URLRequest(url: Uri.parse('https://flutter.dev')),
// initialUrlRequest: // initialUrlRequest:
// URLRequest(url: Uri.parse(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')), // URLRequest(url: Uri.parse(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
// initialFile: "assets/index.html", // initialFile: "assets/index.html",
@ -182,7 +181,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
urlController.text = this.url; urlController.text = this.url;
}); });
}, },
onUpdateVisitedHistory: (controller, url, androidIsReload) { onUpdateVisitedHistory: (controller, url, isReload) {
setState(() { setState(() {
this.url = url.toString(); this.url = url.toString();
urlController.text = this.url; urlController.text = this.url;

View File

@ -9,6 +9,7 @@ import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart
import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart'; import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart'; import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart';
import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart'; import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
// import 'package:path_provider/path_provider.dart'; // import 'package:path_provider/path_provider.dart';
// import 'package:permission_handler/permission_handler.dart'; // import 'package:permission_handler/permission_handler.dart';
@ -26,53 +27,55 @@ Future main() async {
await InAppWebViewController.setWebContentsDebuggingEnabled(true); await InAppWebViewController.setWebContentsDebuggingEnabled(true);
} }
await localhostServer.start(); // await localhostServer.start();
runApp(MyApp()); runApp(MyApp());
} }
Drawer myDrawer({required BuildContext context}) { PointerInterceptor myDrawer({required BuildContext context}) {
return Drawer( return PointerInterceptor(
child: ListView( child: Drawer(
padding: EdgeInsets.zero, child: ListView(
children: <Widget>[ padding: EdgeInsets.zero,
DrawerHeader( children: <Widget>[
child: Text('flutter_inappbrowser example'), DrawerHeader(
decoration: BoxDecoration( child: Text('flutter_inappwebview example'),
color: Colors.blue, decoration: BoxDecoration(
color: Colors.blue,
),
), ),
), ListTile(
ListTile( title: Text('InAppBrowser'),
title: Text('InAppBrowser'), onTap: () {
onTap: () { Navigator.pushReplacementNamed(context, '/InAppBrowser');
Navigator.pushReplacementNamed(context, '/InAppBrowser'); },
}, ),
), ListTile(
ListTile( title: Text('ChromeSafariBrowser'),
title: Text('ChromeSafariBrowser'), onTap: () {
onTap: () { Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser');
Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser'); },
}, ),
), ListTile(
ListTile( title: Text('WebAuthenticationSession'),
title: Text('WebAuthenticationSession'), onTap: () {
onTap: () { Navigator.pushReplacementNamed(context, '/WebAuthenticationSession');
Navigator.pushReplacementNamed(context, '/WebAuthenticationSession'); },
}, ),
), ListTile(
ListTile( title: Text('InAppWebView'),
title: Text('InAppWebView'), onTap: () {
onTap: () { Navigator.pushReplacementNamed(context, '/');
Navigator.pushReplacementNamed(context, '/'); },
}, ),
), ListTile(
ListTile( title: Text('HeadlessInAppWebView'),
title: Text('HeadlessInAppWebView'), onTap: () {
onTap: () { Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView'); },
}, ),
), ],
], ),
), ),
); );
} }

View File

@ -26,6 +26,7 @@ dependencies:
path_provider: ^2.0.9 path_provider: ^2.0.9
permission_handler: ^10.0.2 permission_handler: ^10.0.2
url_launcher: ^6.0.20 url_launcher: ^6.0.20
pointer_interceptor: ^0.9.3+3
# connectivity: ^0.4.5+6 # connectivity: ^0.4.5+6
flutter_inappwebview: flutter_inappwebview:
path: ../ path: ../

View File

@ -12,7 +12,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_web_plugins: flutter_web_plugins:
sdk: flutter sdk: flutter
js: ^0.6.3 js: ^0.6.4
flutter_inappwebview_internal_annotations: ^1.0.0 flutter_inappwebview_internal_annotations: ^1.0.0
dev_dependencies: dev_dependencies: