• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inventree / inventree-app / 15837688195

23 Jun 2025 11:55PM UTC coverage: 1.586% (+0.02%) from 1.566%
15837688195

push

github

web-flow
Format Code and Add Format Checks to CI (#643)

* Remove unused lib/generated/i18n.dart

* Use `fvm dart format .`

* Add contributing guidelines

* Enforce dart format

* Add `dart format off` directive to generated files

133 of 2648 new or added lines in 82 files covered. (5.02%)

430 existing lines in 78 files now uncovered.

771 of 48628 relevant lines covered (1.59%)

0.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.46
/lib/barcode/controller.dart
1
import "package:flutter/material.dart";
2

3
import "package:inventree/preferences.dart";
4
import "package:inventree/barcode/handler.dart";
5
import "package:inventree/widget/progress.dart";
6

7
/*
8
 * Generic class which provides a barcode scanner interface.
9
 * 
10
 * When the controller is instantiated, it is passed a "handler" class,
11
 * which is used to process the scanned barcode.
12
 */
13
class InvenTreeBarcodeController extends StatefulWidget {
14
  const InvenTreeBarcodeController(this.handler, {Key? key}) : super(key: key);
2✔
15

16
  final BarcodeHandler handler;
17

18
  @override
×
19
  State<StatefulWidget> createState() => InvenTreeBarcodeControllerState();
×
20
}
21

22
/*
23
 * Base state widget for the barcode controller.
24
 * This defines the basic interface for the barcode controller.
25
 */
26
class InvenTreeBarcodeControllerState
27
    extends State<InvenTreeBarcodeController> {
28
  InvenTreeBarcodeControllerState() : super();
2✔
29

30
  final GlobalKey barcodeControllerKey = GlobalKey(
31
    debugLabel: "barcodeController",
32
  );
33

34
  // Internal state flag to test if we are currently processing a barcode
35
  bool processingBarcode = false;
36

37
  /*
38
   * Method to handle scanned data.
39
   * Any implementing class should call this method when a barcode is scanned.
40
   * Barcode data should be passed as a string
41
   */
42
  Future<void> handleBarcodeData(String? data) async {
1✔
43
    // Check that the data is valid, and this view is still mounted
44
    if (!mounted || data == null || data.isEmpty) {
2✔
45
      return;
46
    }
47

48
    // Currently processing a barcode - ignore this one
49
    if (processingBarcode) {
1✔
50
      return;
51
    }
52

53
    setState(() {
2✔
54
      processingBarcode = true;
1✔
55
    });
56

57
    showLoadingOverlay();
1✔
58
    await pauseScan();
1✔
59

60
    await widget.handler.processBarcode(data);
3✔
61

62
    // processBarcode may have popped the context
63
    if (!mounted) {
×
64
      hideLoadingOverlay();
×
65
      return;
66
    }
67

68
    int delay =
NEW
69
        await InvenTreeSettingsManager().getValue(INV_BARCODE_SCAN_DELAY, 500)
×
70
            as int;
71

72
    Future.delayed(Duration(milliseconds: delay), () {
×
73
      hideLoadingOverlay();
×
74
      if (mounted) {
×
75
        resumeScan().then((_) {
×
76
          if (mounted) {
×
77
            setState(() {
×
78
              processingBarcode = false;
×
79
            });
80
          }
81
        });
82
      }
83
    });
84
  }
85

86
  // Hook function to "pause" the barcode scanner
87
  Future<void> pauseScan() async {
×
88
    // Implement this function in subclass
89
  }
90

91
  // Hook function to "resume" the barcode scanner
92
  Future<void> resumeScan() async {
×
93
    // Implement this function in subclass
94
  }
95

96
  /*
97
   * Implementing classes are in control of building out the widget
98
   */
99
  @override
×
100
  Widget build(BuildContext context) {
101
    return Container();
×
102
  }
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc