What changed, and why it matters
This commit only reformats Dart source code to match the project's style rules. It does not change what the code does, fix any bug, or alter any security behavior. It is a cosmetic cleanup with no security relevance.
No security action needed. Treat as routine code-style maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure dart format run on two files: lib/widgets/desktop/qr_code_scanner_dialog.dart and test/utilities/camera_preview_capture_test.dart. All changes are whitespace, line wrapping, and indentation adjustments. No logic, identifiers, literals, control flow, or API calls were modified. The camera initialization, QR scanning, error handling, and test logic remain identical.
Changed components
lib/widgets/desktop/qr_code_scanner_dialog.darttest/utilities/camera_preview_capture_test.dartInspect captured patch +45 / −36
### lib/widgets/desktop/qr_code_scanner_dialog.dart
@@ -36,10 +36,12 @@ class QrCodeScannerDialog extends StatefulWidget {
}
class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
- final CameraLinux? _cameraLinuxPlugin =
- Platform.isLinux ? CameraLinux() : null;
- final CameraWindows? _cameraWindowsPlugin =
- Platform.isWindows ? CameraWindows() : null;
+ final CameraLinux? _cameraLinuxPlugin = Platform.isLinux
+ ? CameraLinux()
+ : null;
+ final CameraWindows? _cameraWindowsPlugin = Platform.isWindows
+ ? CameraWindows()
+ : null;
bool _isCameraOpen = false;
Image? _image;
bool _isScanning = false;
@@ -73,7 +75,8 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
unawaited(_captureAndScanImage());
} else if (mounted) {
setState(() {
- _cameraError = "Unable to open the camera"
+ _cameraError =
+ "Unable to open the camera"
"${_initError == null ? "" : " ($_initError)"}. You can "
"still use \"Select file\" to scan a QR code image.";
});
@@ -88,8 +91,8 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
await _cameraLinuxPlugin.initializeCamera();
Logging.instance.d("Linux Camera initialized");
} else if (Platform.isWindows && _cameraWindowsPlugin != null) {
- final List<CameraDescription> cameras =
- await _cameraWindowsPlugin.availableCameras();
+ final List<CameraDescription> cameras = await _cameraWindowsPlugin
+ .availableCameras();
if (cameras.isEmpty) {
throw CameraException('No cameras available', 'No cameras found.');
}
@@ -124,12 +127,15 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
);
// The plugin reports the preview size through this event,
// which it adds before initializeCamera() returns.
- final initialized =
- _cameraWindowsPlugin.onCameraInitialized(_cameraId).first;
+ final initialized = _cameraWindowsPlugin
+ .onCameraInitialized(_cameraId)
+ .first;
await _cameraWindowsPlugin.initializeCamera(_cameraId);
final event = await initialized;
- _windowsPreviewSize =
- Size(event.previewWidth, event.previewHeight);
+ _windowsPreviewSize = Size(
+ event.previewWidth,
+ event.previewHeight,
+ );
opened = true;
break;
} on CameraException catch (e) {
@@ -166,12 +172,11 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
throw Exception('No cameras available');
}
_macOSDeviceId = videoDevices.first.deviceId;
- await CameraMacOS.instance
- .initialize(cameraMacOSMode: CameraMacOSMode.photo);
-
- Logging.instance.d(
- "macOS Camera initialized with ID: $_macOSDeviceId",
+ await CameraMacOS.instance.initialize(
+ cameraMacOSMode: CameraMacOSMode.photo,
);
+
+ Logging.instance.d("macOS Camera initialized with ID: $_macOSDeviceId");
}
return true;
@@ -211,11 +216,7 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
// }
}
} catch (e, s) {
- Logging.instance.e(
- "Failed to stop camera",
- error: e,
- stackTrace: s,
- );
+ Logging.instance.e("Failed to stop camera", error: e, stackTrace: s);
}
}
@@ -245,7 +246,8 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
// toImage() rounds each side up, and the laid-out box is rarely exactly
// the camera's aspect ratio, so take the smaller ratio and stay a hair
// under it. Otherwise a 640x480 camera can come back as 640x481.
- pixelRatio = min(
+ pixelRatio =
+ min(
preview.width * fit / boundary.size.width,
preview.height * fit / boundary.size.height,
) *
@@ -539,8 +541,9 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
}
try {
- final img.Image? image =
- img.decodeImage(File(filePath).readAsBytesSync());
+ final img.Image? image = img.decodeImage(
+ File(filePath).readAsBytesSync(),
+ );
if (image == null) {
await showFloatingFlushBar(
type: FlushBarType.info,
@@ -573,8 +576,7 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
if (context.mounted) {
await showFloatingFlushBar(
type: FlushBarType.info,
- message:
- "Error processing the image. Please try again.",
+ message: "Error processing the image. Please try again.",
iconAsset: Assets.svg.file,
context: context,
);
### test/utilities/camera_preview_capture_test.dart
@@ -52,8 +52,9 @@ class _QrPainter extends CustomPainter {
}
void main() {
- testWidgets("reads a QR code back from a mirrored preview capture",
- (tester) async {
+ testWidgets("reads a QR code back from a mirrored preview capture", (
+ tester,
+ ) async {
final matrix = Encoder.encode(_text, ErrorCorrectionLevel.m).matrix!;
final modules = [
for (var y = 0; y < matrix.height; y++)
@@ -84,8 +85,9 @@ void main() {
final (width, height, rgba) = (await tester.runAsync(() async {
final frame = await boundary.toImage(pixelRatio: 2);
try {
- final bytes =
- await frame.toByteData(format: ui.ImageByteFormat.rawRgba);
+ final bytes = await frame.toByteData(
+ format: ui.ImageByteFormat.rawRgba,
+ );
return (frame.width, frame.height, bytes!.buffer.asUint8List());
} finally {
frame.dispose();
@@ -95,8 +97,11 @@ void main() {
expect((width, height), (side * 2, side * 2));
expect(blankPreviewFrame(rgba), isNull);
- final image =
- imageFromMirroredPreviewRgba(rgba, width: width, height: height);
+ final image = imageFromMirroredPreviewRgba(
+ rgba,
+ width: width,
+ height: height,
+ );
// The marker is back in the top-left once flipped.
final marker = image.getPixel(4, 4);
@@ -113,8 +118,9 @@ void main() {
expect(result.text, _text);
});
- testWidgets("sees a capture with nothing painted as transparent",
- (tester) async {
+ testWidgets("sees a capture with nothing painted as transparent", (
+ tester,
+ ) async {
final key = GlobalKey();
await tester.pumpWidget(
Center(
@@ -130,8 +136,9 @@ void main() {
final rgba = (await tester.runAsync(() async {
final frame = await boundary.toImage();
try {
- final bytes =
- await frame.toByteData(format: ui.ImageByteFormat.rawRgba);
+ final bytes = await frame.toByteData(
+ format: ui.ImageByteFormat.rawRgba,
+ );
return bytes!.buffer.asUint8List();
} finally {
frame.dispose();Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.