feat: pegar QR desde la galería de imágenes - #114
Conversation
…nner.analyzeImage Adds a 'Gallery' button to the QR scanner that lets users pick an image from the device gallery. Uses MobileScannerController.analyzeImage() to decode the QR, reusing the existing mobile_scanner dependency. Closes lachispame#113
|
Warning Review limit reached
More reviews will be available in 59 minutes and 40 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (8)
📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds gallery-based QR decoding to the scanner widget (image selection, decoding, status/error snackbars), adds the image_picker dependency, updates Android plugin version, and provides localized UI strings for gallery selection, decoding progress, "QR not found", and image-loading errors in seven locales. ChangesQR Code Gallery Scanning
Sequence DiagramsequenceDiagram
participant User
participant QRScannerWidget
participant ImagePicker
participant MobileScannerController
participant App
User->>QRScannerWidget: Tap gallery button
QRScannerWidget->>ImagePicker: pickImage(source: gallery)
ImagePicker->>User: Show gallery and return selected image path
ImagePicker->>QRScannerWidget: Return image path
QRScannerWidget->>QRScannerWidget: Show "Decoding..." snackbar
QRScannerWidget->>MobileScannerController: analyzeImage(imagePath)
MobileScannerController->>QRScannerWidget: Return BarcodeCapture
alt QR found
QRScannerWidget->>QRScannerWidget: Set hasScanned, stop camera
QRScannerWidget->>App: onScanned(qrValue)
else No QR detected
QRScannerWidget->>QRScannerWidget: Show "QR not found" snackbar
else Image load error
QRScannerWidget->>QRScannerWidget: Show "Error loading image" snackbar
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/widgets/qr_scanner_widget.dart`:
- Around line 225-231: The catch block that shows the SnackBar in the
QRScannerWidget should not append the raw exception ($e) to the user-facing
message; update the catch in the method that calls
ScaffoldMessenger.of(context).showSnackBar to display only a localized generic
error string from AppLocalizations (e.g.,
AppLocalizations.of(context)!.error_loading_image) and remove "$e" from the
SnackBar content, and separately log the full exception and stack trace using
the app logger or debugPrint inside the same catch (preserve the mounted check
and use ScaffoldMessenger/ SnackBar in the same location).
- Around line 400-420: The gallery IconButton (inside the Container that
triggers _pickFromGallery) lacks an accessibility label; add a localized tooltip
to the IconButton so it consumes the localization key "qr_from_gallery_button"
(e.g. set tooltip to your localization accessor like
AppLocalizations.of(context).qr_from_gallery_button or
context.l10n.qr_from_gallery_button). This will provide an accessible, localized
description for the icon-only control without changing behavior of
_pickFromGallery.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0b8b6968-d7ae-490b-ab60-0741a0726812
⛔ Files ignored due to path filters (9)
lib/l10n/generated/app_localizations.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_de.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_en.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_es.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_fr.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_it.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_pt.dartis excluded by!**/generated/**lib/l10n/generated/app_localizations_ru.dartis excluded by!**/generated/**pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
lib/l10n/app_de.arblib/l10n/app_en.arblib/l10n/app_es.arblib/l10n/app_fr.arblib/l10n/app_it.arblib/l10n/app_pt.arblib/l10n/app_ru.arblib/widgets/qr_scanner_widget.dartpubspec.yaml
…oltip to gallery button
image_picker_android 0.8.13+17 requires androidx.core:core:1.18.0 and androidx.activity:activity:1.12.4, which need AGP >= 8.9.1.
|
Respuesta al check "Out of Scope Changes": El upgrade de AGP 8.7.3 → 8.9.1 es estrictamente necesario y no es scope creep. Razón técnica:
Estas versiones de AndroidX requieren AGP ≥ 8.9.1. No hay forma de usar La alternativa (congelar |
Closes #113
Cambios
pubspec.yaml: añadida dependenciaimage_picker: ^1.1.2lib/widgets/qr_scanner_widget.dart: nuevo botón "Galería" + lógica_pickFromGallery()conMobileScannerController.analyzeImage()lib/l10n/app_*.arb: nuevos strings en 6 idiomaslib/l10n/generated/: regenerado conflutter gen-l10nFlujo
ImagePicker().pickImage()abre el selector del sistemaMobileScannerController.analyzeImage(path)decodifica el QRVerificación
dart analyze lib/widgets/qr_scanner_widget.dart— 0 erroresSummary by CodeRabbit