Julian Steenbakker
Committed by GitHub

Merge branch 'master' into support-multiple-formats-on-ios

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# review when someone opens a pull request.
# For more on how to customize the CODEOWNERS file - https://help.github.com/en/articles/about-code-owners
* @juliansteenbakker
... ...
# .github/workflows/auto-author-assign.yml
name: 'Auto Author Assign'
on:
pull_request_target:
types: [opened, reopened]
permissions:
pull-requests: write
jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.6.1
... ...
... ... @@ -7,7 +7,7 @@
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v3.4.1
- uses: GoogleCloudPlatform/release-please-action@v3.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
... ...
... ... @@ -9,6 +9,9 @@ class MobileScanner extends StatefulWidget {
/// The controller of the camera.
final MobileScannerController? controller;
/// Calls the provided [onPermissionSet] callback when the permission is set.
final Function(bool permissionGranted)? onPermissionSet;
/// Function that gets called when a Barcode is detected.
///
/// [barcode] The barcode object with all information about the scanned code.
... ... @@ -34,6 +37,7 @@ class MobileScanner extends StatefulWidget {
this.controller,
this.fit = BoxFit.cover,
this.allowDuplicates = false,
this.onPermissionSet,
});
@override
... ... @@ -48,7 +52,8 @@ class _MobileScannerState extends State<MobileScanner>
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
controller = widget.controller ?? MobileScannerController();
controller = widget.controller ??
MobileScannerController(onPermissionSet: widget.onPermissionSet);
if (!controller.isStarting) controller.start();
}
... ... @@ -118,7 +123,8 @@ class _MobileScannerState extends State<MobileScanner>
}
} else {
if (widget.controller == null) {
controller = MobileScannerController();
controller =
MobileScannerController(onPermissionSet: widget.onPermissionSet);
} else if (oldWidget.controller != widget.controller) {
controller = widget.controller!;
}
... ...
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
... ... @@ -40,6 +39,7 @@ class MobileScannerController {
static int? _controllerHashcode;
StreamSubscription? events;
Function(bool permissionGranted)? onPermissionSet;
final ValueNotifier<MobileScannerArguments?> args = ValueNotifier(null);
final ValueNotifier<TorchState> torchState = ValueNotifier(TorchState.off);
late final ValueNotifier<CameraFacing> cameraFacingState;
... ... @@ -65,6 +65,7 @@ class MobileScannerController {
this.ratio,
this.torchEnabled,
this.formats,
this.onPermissionSet,
this.autoResume = true,
this.returnImage = false,
}) {
... ... @@ -155,11 +156,14 @@ class MobileScannerController {
state = result
? MobileScannerState.authorized
: MobileScannerState.denied;
onPermissionSet?.call(result);
break;
case MobileScannerState.denied:
isStarting = false;
onPermissionSet?.call(false);
throw PlatformException(code: 'NO ACCESS');
case MobileScannerState.authorized:
onPermissionSet?.call(true);
break;
}
}
... ... @@ -191,6 +195,9 @@ class MobileScannerController {
} on PlatformException catch (error) {
debugPrint('${error.code}: ${error.message}');
isStarting = false;
if (error.code == "MobileScannerWeb") {
onPermissionSet?.call(false);
}
// setAnalyzeMode(AnalyzeMode.none.index);
return;
}
... ... @@ -203,6 +210,10 @@ class MobileScannerController {
hasTorch = startResult['torchable'] as bool? ?? false;
if (kIsWeb) {
onPermissionSet?.call(
true,
); // If we reach this line, it means camera permission has been granted
args.value = MobileScannerArguments(
webId: startResult['ViewID'] as String?,
size: Size(
... ... @@ -286,6 +297,7 @@ class MobileScannerController {
events?.cancel();
events = null;
_controllerHashcode = null;
onPermissionSet = null;
}
barcodesController.close();
}
... ...