scanQR method

Future<String?> scanQR({
  1. String? title,
  2. String? cancelButtonText,
  3. Color? primaryColor,
  4. String? scanInstructions,
  5. bool showFlashlight = true,
  6. bool vibrate = true,
  7. ScannerTheme? theme,
})

Implementation

Future<String?> scanQR({
  String? title,
  String? cancelButtonText,
  Color? primaryColor,
  String? scanInstructions,
  bool showFlashlight = true,
  bool vibrate = true,
  ScannerTheme? theme,
}) async {
  bool hasPermission = await _checkCameraPermission();
  if (!hasPermission) return null;

  primaryColor ??= AppColors.primary;
  final scannerTheme = theme ??
      ScannerTheme(
        primaryColor: primaryColor,
        scanAreaWidth: 260,
        scanAreaHeight: 260,
      );

  final result = await Get.to<String>(
    () => QRScannerScreen(
      title: title ?? 'Scan QR Code',
      cancelButtonText: cancelButtonText ?? 'Cancel',
      scanInstructions:
          scanInstructions ?? 'Position the QR code within the frame to scan',
      theme: scannerTheme,
      showFlashlight: showFlashlight,
      vibrate: vibrate,
    ),
    transition: Transition.downToUp,
    fullscreenDialog: true,
  );

  return result;
}