Skip to content

Commit a6b9a95

Browse files
Merge branch 'feature/flutter_inappwebview_windows'
2 parents 7125bfb + 7b8ebf4 commit a6b9a95

File tree

241 files changed

+20237
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+20237
-230
lines changed

.vscode/settings.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"cmake.configureOnOpen": false,
3+
"files.associations": {
4+
"algorithm": "cpp",
5+
"any": "cpp",
6+
"array": "cpp",
7+
"atomic": "cpp",
8+
"bit": "cpp",
9+
"cctype": "cpp",
10+
"charconv": "cpp",
11+
"chrono": "cpp",
12+
"clocale": "cpp",
13+
"cmath": "cpp",
14+
"compare": "cpp",
15+
"concepts": "cpp",
16+
"coroutine": "cpp",
17+
"cstddef": "cpp",
18+
"cstdint": "cpp",
19+
"cstdio": "cpp",
20+
"cstdlib": "cpp",
21+
"cstring": "cpp",
22+
"ctime": "cpp",
23+
"cwchar": "cpp",
24+
"exception": "cpp",
25+
"format": "cpp",
26+
"forward_list": "cpp",
27+
"functional": "cpp",
28+
"initializer_list": "cpp",
29+
"iomanip": "cpp",
30+
"ios": "cpp",
31+
"iosfwd": "cpp",
32+
"iostream": "cpp",
33+
"istream": "cpp",
34+
"iterator": "cpp",
35+
"limits": "cpp",
36+
"list": "cpp",
37+
"locale": "cpp",
38+
"map": "cpp",
39+
"memory": "cpp",
40+
"new": "cpp",
41+
"optional": "cpp",
42+
"ostream": "cpp",
43+
"ratio": "cpp",
44+
"set": "cpp",
45+
"sstream": "cpp",
46+
"stdexcept": "cpp",
47+
"stop_token": "cpp",
48+
"streambuf": "cpp",
49+
"string": "cpp",
50+
"system_error": "cpp",
51+
"thread": "cpp",
52+
"tuple": "cpp",
53+
"type_traits": "cpp",
54+
"typeinfo": "cpp",
55+
"unordered_map": "cpp",
56+
"utility": "cpp",
57+
"variant": "cpp",
58+
"vector": "cpp",
59+
"xfacet": "cpp",
60+
"xhash": "cpp",
61+
"xiosbase": "cpp",
62+
"xlocale": "cpp",
63+
"xlocbuf": "cpp",
64+
"xlocinfo": "cpp",
65+
"xlocmes": "cpp",
66+
"xlocmon": "cpp",
67+
"xlocnum": "cpp",
68+
"xloctime": "cpp",
69+
"xmemory": "cpp",
70+
"xstring": "cpp",
71+
"xtr1common": "cpp",
72+
"xtree": "cpp",
73+
"xutility": "cpp"
74+
}
75+
}

dev_packages/generators/lib/src/exchangeable_enum_generator.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class ExchangeableEnumGenerator
140140
<DartObject>[];
141141
var hasWebSupport = false;
142142
var webSupportValue = null;
143+
var allPlatformsWithoutValue = true;
143144
if (platforms.isNotEmpty) {
144145
for (var platform in platforms) {
145146
final targetPlatformName =
@@ -150,6 +151,9 @@ class ExchangeableEnumGenerator
150151
? platformValueField.toIntValue() ??
151152
"'${platformValueField.toStringValue()}'"
152153
: null;
154+
if (allPlatformsWithoutValue && platformValue != null) {
155+
allPlatformsWithoutValue = false;
156+
}
153157
if (targetPlatformName == "web") {
154158
hasWebSupport = true;
155159
webSupportValue = platformValue;
@@ -170,8 +174,13 @@ class ExchangeableEnumGenerator
170174
nativeValueBody += "return $defaultValue;";
171175
nativeValueBody += "}";
172176

173-
classBuffer.writeln(
174-
"static final $fieldName = $extClassName._internalMultiPlatform($constantValue, $nativeValueBody);");
177+
if (!allPlatformsWithoutValue) {
178+
classBuffer.writeln(
179+
"static final $fieldName = $extClassName._internalMultiPlatform($constantValue, $nativeValueBody);");
180+
} else {
181+
classBuffer.writeln(
182+
"static const $fieldName = $extClassName._internal($constantValue, ${defaultValue ?? constantValue});");
183+
}
175184
} else {
176185
classBuffer.writeln(
177186
"static const $fieldName = $extClassName._internal($constantValue, $constantValue);");

flutter_inappwebview/example/.metadata

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,27 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: d927c9331005f81157fa39dff7b5dab415ad330b
8-
channel: master
7+
revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
17+
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
18+
- platform: windows
19+
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
20+
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

flutter_inappwebview/example/lib/headless_in_app_webview.screen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class _HeadlessInAppWebViewExampleScreenState
2424
: WebUri("http://localhost:${Uri.base.port}/page.html");
2525

2626
headlessWebView = HeadlessInAppWebView(
27+
webViewEnvironment: webViewEnvironment,
2728
initialUrlRequest: URLRequest(url: url),
2829
initialSettings: InAppWebViewSettings(
2930
isInspectable: kDebugMode,

flutter_inappwebview/example/lib/in_app_browser_example.screen.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class MyInAppBrowser extends InAppBrowser {
1717
: super(
1818
windowId: windowId,
1919
initialUserScripts: initialUserScripts,
20-
pullToRefreshController: pullToRefreshController);
20+
pullToRefreshController: pullToRefreshController,
21+
webViewEnvironment: webViewEnvironment,);
2122

2223
@override
2324
Future onBrowserCreated() async {

flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
115115
children: [
116116
InAppWebView(
117117
key: webViewKey,
118+
webViewEnvironment: webViewEnvironment,
118119
initialUrlRequest:
119120
URLRequest(url: WebUri('https://flutter.dev')),
120121
// initialUrlRequest:

flutter_inappwebview/example/lib/main.dart

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ import 'package:pointer_interceptor/pointer_interceptor.dart';
1515
// import 'package:permission_handler/permission_handler.dart';
1616

1717
final localhostServer = InAppLocalhostServer(documentRoot: 'assets');
18+
WebViewEnvironment? webViewEnvironment;
1819

1920
Future main() async {
2021
WidgetsFlutterBinding.ensureInitialized();
2122
// await Permission.camera.request();
2223
// await Permission.microphone.request();
2324
// await Permission.storage.request();
2425

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+
));
2734
}
2835

29-
if (!kIsWeb) {
30-
await localhostServer.start();
36+
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
37+
await InAppWebViewController.setWebContentsDebuggingEnabled(kDebugMode);
3138
}
3239

3340
runApp(MyApp());
@@ -108,6 +115,28 @@ PointerInterceptor myDrawer({required BuildContext context}) {
108115
},
109116
),
110117
];
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+
];
111140
}
112141
return PointerInterceptor(
113142
child: Drawer(
@@ -160,6 +189,14 @@ class _MyAppState extends State<MyApp> {
160189
'/WebAuthenticationSession': (context) =>
161190
WebAuthenticationSessionExampleScreen(),
162191
});
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+
});
163200
}
164201
return MaterialApp(initialRoute: '/', routes: {
165202
'/': (context) => InAppWebViewExampleScreen(),

flutter_inappwebview/example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ dependency_overrides:
4343
path: ../../flutter_inappwebview_macos
4444
flutter_inappwebview_web:
4545
path: ../../flutter_inappwebview_web
46+
flutter_inappwebview_windows:
47+
path: ../../flutter_inappwebview_windows
4648

4749
dev_dependencies:
4850
flutter_test:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This is a basic Flutter widget test.
2+
//
3+
// To perform an interaction with a widget in your test, use the WidgetTester
4+
// utility in the flutter_test package. For example, you can send tap and scroll
5+
// gestures. You can also use WidgetTester to find child widgets in the widget
6+
// tree, read text, and verify that the values of widget properties are correct.
7+
8+
import 'package:flutter/material.dart';
9+
import 'package:flutter_test/flutter_test.dart';
10+
11+
import 'package:example/main.dart';
12+
13+
void main() {
14+
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15+
// Build our app and trigger a frame.
16+
await tester.pumpWidget(const MyApp());
17+
18+
// Verify that our counter starts at 0.
19+
expect(find.text('0'), findsOneWidget);
20+
expect(find.text('1'), findsNothing);
21+
22+
// Tap the '+' icon and trigger a frame.
23+
await tester.tap(find.byIcon(Icons.add));
24+
await tester.pump();
25+
26+
// Verify that our counter has incremented.
27+
expect(find.text('0'), findsNothing);
28+
expect(find.text('1'), findsOneWidget);
29+
});
30+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
flutter/ephemeral/
2+
3+
# Visual Studio user-specific files.
4+
*.suo
5+
*.user
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# Visual Studio build-related files.
10+
x64/
11+
x86/
12+
13+
# Visual Studio cache files
14+
# files ending in .cache can be ignored
15+
*.[Cc]ache
16+
# but keep track of directories ending in .cache
17+
!*.[Cc]ache/
18+
19+
cmake-build-*

0 commit comments

Comments
 (0)