Skip to content

Commit 317a084

Browse files
Merge pull request #27 from Shunt22/check_permissions
Add check for already granted permissions
2 parents 704118f + ede6d33 commit 317a084

File tree

5 files changed

+68
-23
lines changed

5 files changed

+68
-23
lines changed

example/pubspec.lock

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.8.2"
10+
version: "2.9.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,21 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.2.0"
25-
charcode:
26-
dependency: transitive
27-
description:
28-
name: charcode
29-
url: "https://pub.dartlang.org"
30-
source: hosted
31-
version: "1.3.1"
24+
version: "1.2.1"
3225
clock:
3326
dependency: transitive
3427
description:
3528
name: clock
3629
url: "https://pub.dartlang.org"
3730
source: hosted
38-
version: "1.1.0"
31+
version: "1.1.1"
3932
collection:
4033
dependency: transitive
4134
description:
@@ -56,7 +49,7 @@ packages:
5649
name: fake_async
5750
url: "https://pub.dartlang.org"
5851
source: hosted
59-
version: "1.3.0"
52+
version: "1.3.1"
6053
flutter:
6154
dependency: "direct main"
6255
description: flutter
@@ -101,28 +94,63 @@ packages:
10194
name: matcher
10295
url: "https://pub.dartlang.org"
10396
source: hosted
104-
version: "0.12.11"
97+
version: "0.12.12"
10598
material_color_utilities:
10699
dependency: transitive
107100
description:
108101
name: material_color_utilities
109102
url: "https://pub.dartlang.org"
110103
source: hosted
111-
version: "0.1.4"
104+
version: "0.1.5"
112105
meta:
113106
dependency: transitive
114107
description:
115108
name: meta
116109
url: "https://pub.dartlang.org"
117110
source: hosted
118-
version: "1.7.0"
111+
version: "1.8.0"
119112
path:
120113
dependency: transitive
121114
description:
122115
name: path
123116
url: "https://pub.dartlang.org"
124117
source: hosted
125-
version: "1.8.1"
118+
version: "1.8.2"
119+
permission_handler:
120+
dependency: transitive
121+
description:
122+
name: permission_handler
123+
url: "https://pub.dartlang.org"
124+
source: hosted
125+
version: "10.2.0"
126+
permission_handler_android:
127+
dependency: transitive
128+
description:
129+
name: permission_handler_android
130+
url: "https://pub.dartlang.org"
131+
source: hosted
132+
version: "10.2.0"
133+
permission_handler_apple:
134+
dependency: transitive
135+
description:
136+
name: permission_handler_apple
137+
url: "https://pub.dartlang.org"
138+
source: hosted
139+
version: "9.0.7"
140+
permission_handler_platform_interface:
141+
dependency: transitive
142+
description:
143+
name: permission_handler_platform_interface
144+
url: "https://pub.dartlang.org"
145+
source: hosted
146+
version: "3.9.0"
147+
permission_handler_windows:
148+
dependency: transitive
149+
description:
150+
name: permission_handler_windows
151+
url: "https://pub.dartlang.org"
152+
source: hosted
153+
version: "0.1.2"
126154
plugin_platform_interface:
127155
dependency: transitive
128156
description:
@@ -136,7 +164,7 @@ packages:
136164
path: ".."
137165
relative: true
138166
source: path
139-
version: "0.0.5"
167+
version: "0.0.7"
140168
sky_engine:
141169
dependency: transitive
142170
description: flutter
@@ -148,7 +176,7 @@ packages:
148176
name: source_span
149177
url: "https://pub.dartlang.org"
150178
source: hosted
151-
version: "1.8.2"
179+
version: "1.9.0"
152180
stack_trace:
153181
dependency: transitive
154182
description:
@@ -169,21 +197,21 @@ packages:
169197
name: string_scanner
170198
url: "https://pub.dartlang.org"
171199
source: hosted
172-
version: "1.1.0"
200+
version: "1.1.1"
173201
term_glyph:
174202
dependency: transitive
175203
description:
176204
name: term_glyph
177205
url: "https://pub.dartlang.org"
178206
source: hosted
179-
version: "1.2.0"
207+
version: "1.2.1"
180208
test_api:
181209
dependency: transitive
182210
description:
183211
name: test_api
184212
url: "https://pub.dartlang.org"
185213
source: hosted
186-
version: "0.4.9"
214+
version: "0.4.12"
187215
vector_math:
188216
dependency: transitive
189217
description:
@@ -225,7 +253,7 @@ packages:
225253
name: webview_windows
226254
url: "https://pub.dartlang.org"
227255
source: hosted
228-
version: "0.2.0"
256+
version: "0.2.2"
229257
sdks:
230258
dart: ">=2.17.0 <3.0.0"
231-
flutter: ">=3.0.0"
259+
flutter: ">=3.3.0"

example/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <permission_handler_windows/permission_handler_windows_plugin.h>
910
#include <webview_windows/webview_windows_plugin.h>
1011

1112
void RegisterPlugins(flutter::PluginRegistry* registry) {
13+
PermissionHandlerWindowsPluginRegisterWithRegistrar(
14+
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
1215
WebviewWindowsPluginRegisterWithRegistrar(
1316
registry->GetRegistrarForPlugin("WebviewWindowsPlugin"));
1417
}

example/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
permission_handler_windows
67
webview_windows
78
)
89

lib/screens/window.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:io';
33

44
import 'package:flutter/material.dart';
55
import 'package:path/path.dart' as p;
6+
import 'package:permission_handler/permission_handler.dart';
67
import 'package:simple_barcode_scanner/constant.dart';
78
import 'package:simple_barcode_scanner/enum.dart';
89
import 'package:webview_windows/webview_windows.dart';
@@ -31,6 +32,12 @@ class WindowBarcodeScanner extends StatelessWidget {
3132
Widget build(BuildContext context) {
3233
WebviewController controller = WebviewController();
3334
bool isPermissionGranted = false;
35+
36+
_checkCameraPermission().then((granted) {
37+
debugPrint("Permission is $granted");
38+
isPermissionGranted = granted;
39+
});
40+
3441
return Scaffold(
3542
appBar: AppBar(
3643
title: Text(appBarTitle ?? kScanPageTitle),
@@ -73,6 +80,11 @@ class WindowBarcodeScanner extends StatelessWidget {
7380
);
7481
}
7582

83+
/// Checks if camera permission has already been granted
84+
Future<bool> _checkCameraPermission() async {
85+
return await Permission.camera.status.isGranted;
86+
}
87+
7688
Future<WebviewPermissionDecision> _onPermissionRequested(
7789
{required String url,
7890
required WebviewPermissionKind kind,

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ dependencies:
2323
flutter_barcode_scanner: ^2.0.0
2424
#Get assets path for window platform
2525
path: ^1.8.2
26-
26+
#checking permissions
27+
permission_handler: ^10.2.0
2728
dev_dependencies:
2829
flutter_test:
2930
sdk: flutter

0 commit comments

Comments
 (0)