onScan method Null safety

Future<bool> onScan(
  1. String? code
)

Adds a barcode Will return true if this barcode is successfully added

Implementation

Future<bool> onScan(String? code) async {
  if (code == null) {
    return false;
  }

  if (_barcodeTrustCheck != code) {
    _barcodeTrustCheck = code;
    return false;
  }
  if (_latestScannedBarcode == code || _barcodes.contains(code)) {
    lastConsultedBarcode = code;
    return false;
  }
  AnalyticsHelper.trackScannedProduct(barcode: code);

  _latestScannedBarcode = code;
  return _addBarcode(code);
}