Skip to content

feat: pegar QR desde la galería de imágenes - #114

Open
Delgado74 wants to merge 4 commits into
lachispame:mainfrom
Delgado74:feature/qr-from-gallery
Open

feat: pegar QR desde la galería de imágenes#114
Delgado74 wants to merge 4 commits into
lachispame:mainfrom
Delgado74:feature/qr-from-gallery

Conversation

@Delgado74

@Delgado74 Delgado74 commented May 24, 2026

Copy link
Copy Markdown
Contributor

Closes #113

Cambios

  • pubspec.yaml: añadida dependencia image_picker: ^1.1.2
  • lib/widgets/qr_scanner_widget.dart: nuevo botón "Galería" + lógica _pickFromGallery() con MobileScannerController.analyzeImage()
  • lib/l10n/app_*.arb: nuevos strings en 6 idiomas
  • lib/l10n/generated/: regenerado con flutter gen-l10n

Flujo

  1. Usuario pulsa botón galería en el scanner QR
  2. ImagePicker().pickImage() abre el selector del sistema
  3. MobileScannerController.analyzeImage(path) decodifica el QR
  4. Resultado procesado igual que escaneo por cámara

Verificación

  • dart analyze lib/widgets/qr_scanner_widget.dart — 0 errores

Summary by CodeRabbit

  • New Features
    • Added gallery selection for QR scanning so users can choose an image to decode.
    • Improved QR scanning user flow with expanded localized feedback (DE, EN, ES, FR, IT, PT, RU): gallery button, decoding progress, “QR not found” message, and image-load error messages.

Review Change Stack

…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
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Delgado74, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d1800bf-d7e5-4d2d-8341-84a401260684

📥 Commits

Reviewing files that changed from the base of the PR and between 13b47e7 and 7816b22.

⛔ Files ignored due to path filters (8)
  • lib/l10n/generated/app_localizations.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_de.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_en.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_es.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_fr.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_it.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_pt.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_ru.dart is excluded by !**/generated/**
📒 Files selected for processing (7)
  • lib/l10n/app_de.arb
  • lib/l10n/app_en.arb
  • lib/l10n/app_es.arb
  • lib/l10n/app_fr.arb
  • lib/l10n/app_it.arb
  • lib/l10n/app_pt.arb
  • lib/l10n/app_ru.arb
📝 Walkthrough

Walkthrough

Adds 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.

Changes

QR Code Gallery Scanning

Layer / File(s) Summary
Widget implementation, dependency & build update
pubspec.yaml, lib/widgets/qr_scanner_widget.dart, android/settings.gradle.kts
Adds image_picker: 1.1.1, imports image_picker, implements _pickFromGallery() that picks an image and calls controller.analyzeImage(path), shows localized decoding/not-found/error snackbars, adds a gallery icon button to the camera footer, and updates the Android Gradle plugin version.
Localization strings across locales
lib/l10n/app_en.arb, lib/l10n/app_de.arb, lib/l10n/app_es.arb, lib/l10n/app_fr.arb, lib/l10n/app_it.arb, lib/l10n/app_pt.arb, lib/l10n/app_ru.arb
Adds four new i18n keys in each locale: qr_from_gallery_button, qr_decoding, qr_not_found_in_image, and error_loading_image to support the gallery-decoding flow and related status/error messages.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • lachispame/lachispa#103: Modifies lib/widgets/qr_scanner_widget.dart and locale files to localize QR scanner UI; related to localization and QR scanner UI changes in this PR.

Poem

🐰 I hopped to pick a picture bright,
Tap the gallery, watch the light,
Decoding hums, a tiny cheer,
If no QR lives, a message clear,
Seven tongues sing: your code is here.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive The android/settings.gradle.kts AGP version upgrade (8.7.3→8.9.1) appears justified per PR objectives as a dependency requirement, though it falls outside the main QR gallery feature scope. Clarify whether the AGP upgrade is mandatory for image_picker_android compatibility or if it represents scope creep; consider moving to a separate infrastructure PR if not strictly required.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main feature: adding QR code decoding from device gallery images, which aligns with the primary change across all modified files.
Linked Issues check ✅ Passed The PR fulfills most core requirements from issue #113: image_picker dependency added, gallery selection implemented in qr_scanner_widget.dart with analyzeImage() integration, localization strings added for 6 languages, and error handling with SnackBars.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 66b1d1e and 404e693.

⛔ Files ignored due to path filters (9)
  • lib/l10n/generated/app_localizations.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_de.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_en.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_es.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_fr.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_it.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_pt.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_ru.dart is excluded by !**/generated/**
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • lib/l10n/app_de.arb
  • lib/l10n/app_en.arb
  • lib/l10n/app_es.arb
  • lib/l10n/app_fr.arb
  • lib/l10n/app_it.arb
  • lib/l10n/app_pt.arb
  • lib/l10n/app_ru.arb
  • lib/widgets/qr_scanner_widget.dart
  • pubspec.yaml

Comment thread lib/widgets/qr_scanner_widget.dart
Comment thread lib/widgets/qr_scanner_widget.dart
Delgado74 added 2 commits May 24, 2026 20:08
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.
@Delgado74

Delgado74 commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

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:

image_picker: 1.1.1 resuelve image_picker_android: 0.8.13+17 como dependencia transitiva, el cual declara en su build.gradle.kts:

  • androidx.core:core:1.18.0
  • androidx.activity:activity:1.12.4

Estas versiones de AndroidX requieren AGP ≥ 8.9.1. No hay forma de usar image_picker con estas dependencias sin actualizar el AGP.

La alternativa (congelar image_picker_android a 0.8.13+15) sería frágil y evitaría parches de seguridad, por lo que la decisión correcta es mantener AGP 8.9.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: pegar QR desde la galería de imágenes

1 participant