updated example main.dart
This commit is contained in:
parent
17d8aa1167
commit
30102a5c1a
|
@ -1,21 +1,69 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
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 {
|
Future main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// await Permission.camera.request();
|
||||||
|
// await Permission.storage.request();
|
||||||
|
// await localhostServer.start();
|
||||||
runApp(MyApp());
|
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 {
|
class MyApp extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_MyAppState createState() => new _MyAppState();
|
_MyAppState createState() => new _MyAppState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
InAppWebViewController webView;
|
|
||||||
CookieManager _cookieManager = CookieManager.instance();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -30,46 +78,13 @@ class _MyAppState extends State<MyApp> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
home: Scaffold(
|
initialRoute: '/',
|
||||||
appBar: AppBar(
|
routes: {
|
||||||
title: const Text('InAppWebView Example'),
|
'/': (context) => InAppWebViewExampleScreen(),
|
||||||
),
|
'/InAppBrowser': (context) => InAppBrowserExampleScreen(),
|
||||||
body: Container(
|
'/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(),
|
||||||
child: Column(children: <Widget>[
|
'/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(),
|
||||||
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 {
|
|
||||||
|
|
||||||
},
|
|
||||||
))
|
|
||||||
])),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue