diff --git a/example/lib/main.dart b/example/lib/main.dart index 1eddcc9f..82f75941 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -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: [ + 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 { - InAppWebViewController webView; - CookieManager _cookieManager = CookieManager.instance(); @override void initState() { @@ -30,46 +78,13 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('InAppWebView Example'), - ), - body: Container( - child: Column(children: [ - 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(), + } ); } -} +} \ No newline at end of file