updated example main.dart

This commit is contained in:
Lorenzo Pichilli 2020-06-03 01:48:27 +02:00
parent 17d8aa1167
commit 30102a5c1a
1 changed files with 60 additions and 45 deletions

View File

@ -1,21 +1,69 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_inappwebview_example/chrome_safari_browser_example.screen.dart';
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_browser_example.screen.dart';
// import 'package:permission_handler/permission_handler.dart';
// InAppLocalhostServer localhostServer = new InAppLocalhostServer();
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
// await Permission.camera.request();
// await Permission.storage.request();
// await localhostServer.start();
runApp(MyApp());
}
Drawer myDrawer({@required BuildContext context}) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('flutter_inappbrowser example'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('InAppBrowser'),
onTap: () {
Navigator.pushReplacementNamed(context, '/InAppBrowser');
},
),
ListTile(
title: Text('ChromeSafariBrowser'),
onTap: () {
Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser');
},
),
ListTile(
title: Text('InAppWebView'),
onTap: () {
Navigator.pushReplacementNamed(context, '/');
},
),
ListTile(
title: Text('HeadlessInAppWebView'),
onTap: () {
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
},
),
],
),
);
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
InAppWebViewController webView;
CookieManager _cookieManager = CookieManager.instance();
@override
void initState() {
@ -30,46 +78,13 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('InAppWebView Example'),
),
body: Container(
child: Column(children: <Widget>[
Expanded(
child: InAppWebView(
initialUrl: "https://github.com/",
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true
),
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {},
onLoadStop: (InAppWebViewController controller, String url) async {
},
)),
Expanded(
child: InAppWebView(
initialUrl: "https://github.com/",
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true
),
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {},
onLoadStop: (InAppWebViewController controller, String url) async {
},
))
])),
),
initialRoute: '/',
routes: {
'/': (context) => InAppWebViewExampleScreen(),
'/InAppBrowser': (context) => InAppBrowserExampleScreen(),
'/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(),
'/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(),
}
);
}
}
}