I was able to implement this flutter package: https://pub.dev/packages/honeywell_scanner
I am now trying to use the examples that are provided here: https://pub.dev/packages/honeywell_scanner/example
The problem is that my IDE is showing errors pointing to 3 lines (noted below). I just started a new flutter project, so there is nothing overly complex going on in it. The app only consists of main.dart which opens scan.dart.
import 'package:flutter/material.dart'; import 'package:honeywell_scanner/honeywell_scanner.dart';
class Scan extends StatefulWidget {
const Scan({Key? key}) : super(key: key);
@override
State<Scan> createState() => _ScanState();
}
class _ScanState extends State<Scan> {
//...//
@override
initState() {
super.initState();
WidgetsBinding.instance.addObserver(this); //Error here: The argument type '_ScanState' can't be assigned to the parameter type 'WidgetsBindingObserver'.
honeywellScanner.scannerCallback = this; //Error here: A value of type '_ScanState' can't be assigned to a variable of type 'ScannerCallback'.
initialize();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state); //Error here: Superclass has no method named 'didChangeAppLifecycleState'.
switch (state) {
case AppLifecycleState.resumed:
honeywellScanner.resumeScanner();
break;
case AppLifecycleState.inactive:
honeywellScanner.pauseScanner();
break;
case AppLifecycleState
.paused: //AppLifecycleState.paused is used as stopped state because deactivate() works more as a pause for lifecycle
honeywellScanner.pauseScanner();
break;
case AppLifecycleState.detached:
honeywellScanner.pauseScanner();
break;
default:
break;
}
}
//...//
Was missing the following:
and then for the
didChangeAppLifecycleStateI just removedsuper.