mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 10:15:32 +00:00
Refactor barcode scann function
- Provide a custom callback to be executed when the barcode is scanned
This commit is contained in:
@ -6,8 +6,32 @@
|
||||
* Simplify a numerical value into a string,
|
||||
* supressing trailing zeroes
|
||||
*/
|
||||
|
||||
import "package:audioplayers/audioplayers.dart";
|
||||
import "package:inventree/app_settings.dart";
|
||||
|
||||
String simpleNumberString(double number) {
|
||||
// Ref: https://stackoverflow.com/questions/55152175/how-to-remove-trailing-zeros-using-dart
|
||||
|
||||
return number.toStringAsFixed(number.truncateToDouble() == number ? 0 : 1);
|
||||
}
|
||||
|
||||
Future<void> successTone() async {
|
||||
|
||||
final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
|
||||
if (en) {
|
||||
final player = AudioCache();
|
||||
player.play("sounds/barcode_scan.mp3");
|
||||
}
|
||||
}
|
||||
|
||||
Future <void> failureTone() async {
|
||||
|
||||
final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
|
||||
if (en) {
|
||||
final player = AudioCache();
|
||||
player.play("sounds/barcode_error.mp3");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user