How to set detection intervals ? #39
-
Thanks for the cool scanner. ❤️ I want an arbitrary interval to occur before the next execution of a function written to I'm new to mobile development and Flutter, so sorry if I'm asking off the mark. |
Beta Was this translation helpful? Give feedback.
Answered by
juliansteenbakker
Mar 4, 2022
Replies: 1 comment 1 reply
-
You can work with intervals, but something that is more suitable is maybe to check on duplicates. An interval can be something like Timer? _timer; // Declared in your statefull class
// onDetect function of MobileScanner
onDetect: (barcode, args) {
if (_timer == null || !_timer!.isActive) {
_timer = Timer(Duration(seconds: 2), () {});
// do something
}
} To check on duplicates you can do something like this: String? barcode; // Declared in your statefull class
// onDetect function of MobileScanner
onDetect: (barcode, args) {
if (this.barcode != barcode.rawValue) {
// New barcode found !!
setState(() {
this.barcode = barcode.rawValue;
});
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
utamori
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can work with intervals, but something that is more suitable is maybe to check on duplicates.
An interval can be something like
To check on duplicates you can do something like this: