scan_tally_mobile_scanner
Camera adapter that connects mobile_scanner to scan_tally. With it, a camera counts items the way a stock count needs:
- each item counts once while it stays in view;
- it counts again after it leaves the view and comes back (or after a cooldown);
- blurry misreads are filtered by N-frame confirmation;
- you get undo, a validator, GS1 parsing and feedback from
scan_tally.
Installation
dependencies:
scan_tally: ^0.1.0
scan_tally_mobile_scanner: ^0.1.0
mobile_scanner: ^7.3.0
Follow the platform setup of mobile_scanner (camera permission text on iOS/macOS).
Usage
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:scan_tally/scan_tally_flutter.dart';
import 'package:scan_tally_mobile_scanner/scan_tally_mobile_scanner.dart';
final controller = MobileScannerSource.createController();
final session = ScanSession(
dedupe: const DedupePolicy.leaveAndReturn(),
confirmation: const FrameConfirmation(frames: 2),
feedbackPlayer: const FlutterScanFeedbackPlayer(),
);
session.attach(MobileScannerSource(controller));
// build:
ScanFlash(session: session, child: MobileScanner(controller: controller));
createController() returns a controller with DetectionSpeed.normal and a detection timeout of 150 ms, so a code in view is reported about every 150 ms.
Do not use DetectionSpeed.noDuplicates. It hides the repeated reads that scan_tally needs to know a code is still in view, so leave-and-return counting and frame confirmation stop working.
If you already use MobileScanner(onDetect: ...), feed the captures to MobileScannerSource.fromCaptures(stream) instead.
Each BarcodeCapture becomes one continuous ScanFrame. BarcodeFormat is mapped to ScanSymbology, so EAN/UPC codes get check-digit validation. Errors on the controller stream are skipped.
Compatibility
| scan_tally_mobile_scanner | mobile_scanner | scan_tally | Flutter |
|---|---|---|---|
| 0.1.x | >=7.3.0 <8.0.0 (developed with 7.4.2, analyzed and tested against 7.3.0) |
^0.1.0 | ≥ 3.32 |
mobile_scanner 7.0–7.2 lack some BarcodeFormat values this adapter maps, so 7.3.0 is the lower bound. A new major version of mobile_scanner gets a new adapter release after testing.
Why a separate package?
- The core
scan_tallyhas no camera dependency. Apps that only use hardware (keyboard wedge) scanners do not ship a camera plugin, ML Kit or the camera permission. - Camera plugin API changes only touch this small adapter.
- To connect another scanner plugin, implement
ScanSource(aStream<ScanFrame>) the same way; seemobile_scanner_source.dart.
Status
Compiled and unit tested with simulated captures. In this release it has not yet been tried on a physical device.
License
MIT
Türkçe
mobile_scanner paketini scan_tally'ye bağlayan ince kamera adaptörü. Kamerayla stok sayımına uygun şekilde sayım yapılır:
- her ürün görüntüde kaldığı sürece bir kez sayılır;
- görüntüden çıkıp geri gelince (ya da bekleme süresi dolunca) yeniden sayılır;
- bulanık görüntüden gelen yanlış okumalar art arda N kare şartıyla ayıklanır;
- geri alma, doğrulama, GS1 çözümleme ve geri bildirim
scan_tally'den gelir.
Kullanım
Kod örneği yukarıdaki İngilizce bölümdedir.
MobileScannerSource.createController()önerilen ayarlarla bir denetleyici döndürür:DetectionSpeed.normalve 150 ms algılama aralığı.DetectionSpeed.noDuplicateskullanmayın. Bu mod, kodun hâlâ görüntüde olduğunu anlamak için gereken tekrar okumaları gizler.MobileScanner(onDetect: ...)kullanıyorsanız yakalamalarıMobileScannerSource.fromCaptures(stream)ile verin.
Uyumluluk
- scan_tally_mobile_scanner 0.1.x, mobile_scanner
>=7.3.0 <8.0.0ile çalışır.- 7.4.2 ile geliştirildi; 7.3.0'a karşı analiz edildi ve test edildi.
- 7.0–7.2'de bu adaptörün eşlediği bazı
BarcodeFormatdeğerleri yok.
- Yeni bir ana
mobile_scannersürümü, test edildikten sonra yeni bir adaptör sürümüyle desteklenir.
Neden ayrı paket?
- Çekirdek paketin kamera bağımlılığı yoktur. Yalnızca el terminali kullanan bir uygulama kamera eklentisi, ML Kit ve kamera izni taşımaz.
- Kamera eklentisindeki API değişiklikleri yalnızca bu küçük adaptörü etkiler.
- Başka bir tarayıcı paketini bağlamak için
ScanSourcearayüzünü aynı şekilde uygulayın.
Durum
Derlendi ve benzetilmiş yakalamalarla birim testlerinden geçti. Bu sürümde fiziksel cihazda henüz denenmedi.
Lisans
MIT
Libraries
- scan_tally_mobile_scanner
- Connects mobile_scanner to scan_tally.