A flutter plugin for scanning Barcodes & QR codes with different scanners.
- MLKit Scanner
- ZXing Scanner
- Vision Scanner
Add google play services dependency on app's gradle file.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: "com.google.gms.google-services"
Download and add 'google-services.json' from Firebase to your project.
Init Firebase.
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//Initialize Scanner
ScannerHelper.init(this)
}
}
Setup listener for ZXing scanner.
class MainActivity : FlutterActivity() {
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
ScannerHelper.parseZXingResult(resultCode, data)?.let {
Log.i("parseZXingResult", "onActivityResult: $it")
CubivueScannersPlugin.eventSink?.success(ScanResult(it, ScannerType.ZXING.value).toString())
}
super.onActivityResult(requestCode, resultCode, data)
}
}
In your pubspec.yaml
dependencies:
cubivue_scanners: [LATEST_VERSION]
import 'package:cubivue_scanners/cubivue_scanners.dart';
var _service = CubivueScanners();
_service.startScannerService();
_service.getScanResults().onData((data) {
print("getScanResults: ${data.result} , ${data.scannerType}");
});
await _service.startMLKitScanner;
await _service.startZXingScanner;
await _service.startVisionScanner;
cubivue_scanners plugin is developed by CubiVue Developers. You can email us at embraceitcubivue@gmail.com for any queries.