fix: probe scanner method channel to detect MissingPluginException (#204) #221

Merged
guettlibot merged 2 commits from issue-204-fix into main 2026-05-24 13:55:14 +00:00
guettlibot commented 2026-05-24 13:48:20 +00:00 (Migrated from codeberg.org)

Summary

  • Root cause: the previous _initScanner() pre-flight called ctrl.start() without first calling ctrl.attach(), so MobileScannerController always timed out after 500 ms with a controllerNotAttached error — the scanner never worked on any device
  • Fix: replace with a targeted invokeMethod('state') probe on the scanner method channel; MissingPluginException (the exact error in the crash report) is caught and falls back to text input, while all other errors let the MobileScanner widget handle them via its own error builder
  • Tests: add three new widget tests for AccountReceiveScreen step-2 flow — text-fallback visible on non-camera platforms, successful import via text input, and friendly error display for invalid QR codes

Test plan

  • flutter analyze — no issues
  • flutter test test/unit/ test/widget/ — 450 tests pass (8 tests in account_export_screen_test.dart including the 3 new step-2 cases)
  • On Android with a working scanner: camera view should now appear (scanner was previously always replaced by text fallback due to the broken pre-flight)
  • On Android without the scanner plugin: text fallback shown, no crash

🤖 Generated with Claude Code

## Summary - **Root cause**: the previous `_initScanner()` pre-flight called `ctrl.start()` without first calling `ctrl.attach()`, so `MobileScannerController` always timed out after 500 ms with a `controllerNotAttached` error — the scanner never worked on any device - **Fix**: replace with a targeted `invokeMethod('state')` probe on the scanner method channel; `MissingPluginException` (the exact error in the crash report) is caught and falls back to text input, while all other errors let the `MobileScanner` widget handle them via its own error builder - **Tests**: add three new widget tests for `AccountReceiveScreen` step-2 flow — text-fallback visible on non-camera platforms, successful import via text input, and friendly error display for invalid QR codes ## Test plan - [ ] `flutter analyze` — no issues - [ ] `flutter test test/unit/ test/widget/` — 450 tests pass (8 tests in `account_export_screen_test.dart` including the 3 new step-2 cases) - [ ] On Android with a working scanner: camera view should now appear (scanner was previously always replaced by text fallback due to the broken pre-flight) - [ ] On Android without the scanner plugin: text fallback shown, no crash 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.