updated example

This commit is contained in:
Lorenzo Pichilli 2022-10-14 09:36:00 +02:00
parent 30d041283b
commit ba2c702665

@ -21,7 +21,7 @@ Future main() async {
// await Permission.microphone.request(); // await Permission.microphone.request();
// await Permission.storage.request(); // await Permission.storage.request();
if (defaultTargetPlatform == TargetPlatform.android) { if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
await InAppWebViewController.setWebContentsDebuggingEnabled(true); await InAppWebViewController.setWebContentsDebuggingEnabled(true);
} }
@ -33,17 +33,16 @@ Future main() async {
} }
PointerInterceptor myDrawer({required BuildContext context}) { PointerInterceptor myDrawer({required BuildContext context}) {
return PointerInterceptor( final children = [
child: Drawer( ListTile(
child: ListView( title: Text('InAppWebView'),
padding: EdgeInsets.zero, onTap: () {
children: <Widget>[ Navigator.pushReplacementNamed(context, '/');
DrawerHeader( },
child: Text('flutter_inappwebview example'), )
decoration: BoxDecoration( ];
color: Colors.blue, if (!kIsWeb) {
), children.addAll([
),
ListTile( ListTile(
title: Text('InAppBrowser'), title: Text('InAppBrowser'),
onTap: () { onTap: () {
@ -62,18 +61,26 @@ PointerInterceptor myDrawer({required BuildContext context}) {
Navigator.pushReplacementNamed(context, '/WebAuthenticationSession'); Navigator.pushReplacementNamed(context, '/WebAuthenticationSession');
}, },
), ),
ListTile(
title: Text('InAppWebView'),
onTap: () {
Navigator.pushReplacementNamed(context, '/');
},
),
ListTile( ListTile(
title: Text('HeadlessInAppWebView'), title: Text('HeadlessInAppWebView'),
onTap: () { onTap: () {
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView'); Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
}, },
), ),
]);
}
return PointerInterceptor(
child: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('flutter_inappwebview example'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
...children
], ],
), ),
), ),
@ -98,6 +105,11 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (kIsWeb) {
return MaterialApp(initialRoute: '/', routes: {
'/': (context) => InAppWebViewExampleScreen(),
});
}
return MaterialApp(initialRoute: '/', routes: { return MaterialApp(initialRoute: '/', routes: {
'/': (context) => InAppWebViewExampleScreen(), '/': (context) => InAppWebViewExampleScreen(),
'/InAppBrowser': (context) => InAppBrowserExampleScreen(), '/InAppBrowser': (context) => InAppBrowserExampleScreen(),