start static method

Future<void> start({
  1. Duration cooldown = const Duration(seconds: 2),
})

Implementation

static Future<void> start({Duration cooldown = const Duration(seconds: 2)}) async {
  if (_active) return;
  _active = true;
  _paused = false;
  while (_active) {
    if (_paused) {
      await Future.delayed(const Duration(milliseconds: 500));
      continue;
    }
    try {
      final card = await capture();
      if (_prevId == card.id && _prevTime != null && DateTime.now().difference(_prevTime!) < cooldown) continue;
      _prevId = card.id;
      _prevTime = DateTime.now();
      _tagStream.add(card);
      await Future.delayed(cooldown);
    } catch (e) {
      if (e is! NfcIssue) break;
    }
  }
  _active = false;
}