Skip to content

Commit

Permalink
updated example main.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Jun 2, 2020
1 parent 17d8aa1 commit 30102a5
Showing 1 changed file with 60 additions and 45 deletions.
105 changes: 60 additions & 45 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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(),
}
);
}
}
}

0 comments on commit 30102a5

Please sign in to comment.