@@ -15,19 +15,26 @@ import 'package:pointer_interceptor/pointer_interceptor.dart';
15
15
// import 'package:permission_handler/permission_handler.dart';
16
16
17
17
final localhostServer = InAppLocalhostServer (documentRoot: 'assets' );
18
+ WebViewEnvironment ? webViewEnvironment;
18
19
19
20
Future main () async {
20
21
WidgetsFlutterBinding .ensureInitialized ();
21
22
// await Permission.camera.request();
22
23
// await Permission.microphone.request();
23
24
// await Permission.storage.request();
24
25
25
- if (! kIsWeb && defaultTargetPlatform == TargetPlatform .android) {
26
- await InAppWebViewController .setWebContentsDebuggingEnabled (kDebugMode);
26
+ if (! kIsWeb && defaultTargetPlatform == TargetPlatform .windows) {
27
+ final availableVersion = await WebViewEnvironment .getAvailableVersion ();
28
+ assert (availableVersion != null , 'Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.' );
29
+
30
+ webViewEnvironment = await WebViewEnvironment .create (settings:
31
+ WebViewEnvironmentSettings (
32
+ userDataFolder: 'custom_path'
33
+ ));
27
34
}
28
35
29
- if (! kIsWeb) {
30
- await localhostServer. start ( );
36
+ if (! kIsWeb && defaultTargetPlatform == TargetPlatform .android ) {
37
+ await InAppWebViewController . setWebContentsDebuggingEnabled (kDebugMode );
31
38
}
32
39
33
40
runApp (MyApp ());
@@ -108,6 +115,28 @@ PointerInterceptor myDrawer({required BuildContext context}) {
108
115
},
109
116
),
110
117
];
118
+ } else if (defaultTargetPlatform == TargetPlatform .windows ||
119
+ defaultTargetPlatform == TargetPlatform .linux) {
120
+ children = [
121
+ ListTile (
122
+ title: Text ('InAppWebView' ),
123
+ onTap: () {
124
+ Navigator .pushReplacementNamed (context, '/' );
125
+ },
126
+ ),
127
+ ListTile (
128
+ title: Text ('InAppBrowser' ),
129
+ onTap: () {
130
+ Navigator .pushReplacementNamed (context, '/InAppBrowser' );
131
+ },
132
+ ),
133
+ ListTile (
134
+ title: Text ('HeadlessInAppWebView' ),
135
+ onTap: () {
136
+ Navigator .pushReplacementNamed (context, '/HeadlessInAppWebView' );
137
+ },
138
+ ),
139
+ ];
111
140
}
112
141
return PointerInterceptor (
113
142
child: Drawer (
@@ -160,6 +189,14 @@ class _MyAppState extends State<MyApp> {
160
189
'/WebAuthenticationSession' : (context) =>
161
190
WebAuthenticationSessionExampleScreen (),
162
191
});
192
+ } else if (defaultTargetPlatform == TargetPlatform .windows ||
193
+ defaultTargetPlatform == TargetPlatform .linux) {
194
+ return MaterialApp (initialRoute: '/' , routes: {
195
+ '/' : (context) => InAppWebViewExampleScreen (),
196
+ '/InAppBrowser' : (context) => InAppBrowserExampleScreen (),
197
+ '/HeadlessInAppWebView' : (context) =>
198
+ HeadlessInAppWebViewExampleScreen (),
199
+ });
163
200
}
164
201
return MaterialApp (initialRoute: '/' , routes: {
165
202
'/' : (context) => InAppWebViewExampleScreen (),
0 commit comments