initialize static method

Future<bool> initialize()

Initialize the Zebra Scanner

This sets up the DataWedge profile and prepares the scanner for use. Must be called before using other methods.

Returns true if initialization was successful

Implementation

static Future<bool> initialize() async {
  if (_isInitialized) {
    return true;
  }

  try {
    // Ensure controllers are created
    _scanResultController ??= StreamController<ScanResult>.broadcast();
    _statusController ??= StreamController<ScannerStatus>.broadcast();

    _channel.setMethodCallHandler(_handleMethodCall);

    await _channel.invokeMethod('initializeScanner');

    _isInitialized = true;
    _updateStatus(ScannerStatus.ready);

    return true;
  } on PlatformException catch (e) {
    _updateStatus(ScannerStatus.error);
    throw Exception('Failed to initialize scanner: ${e.message}');
  }
}