Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome and safari in ios 18.1.1 cannot show widget #1320

Open
yeewan98 opened this issue Feb 6, 2025 · 3 comments
Open

Chrome and safari in ios 18.1.1 cannot show widget #1320

yeewan98 opened this issue Feb 6, 2025 · 3 comments

Comments

@yeewan98
Copy link

yeewan98 commented Feb 6, 2025

I had test in other version of ios for chrome and safari, it does not have the problem as below, but only in ios 18.1.1 it show the error below.

Flutter ver 3.27.1

class ScanScreen extends StatefulWidget {
  final OnScanned onScanned;
  final VoidCallback onClose;
  final bool isBusyScanning;
  ScanScreen({required this.onScanned, required this.onClose, super.key, this.isBusyScanning = false});

  @override
  State<ScanScreen> createState() => _ScanScreenState();
}

class _ScanScreenState extends State<ScanScreen> {
  final MobileScannerController controller = MobileScannerController(
    formats: const [BarcodeFormat.qrCode],
  );
  final AudioPlayer player = AudioPlayer();

  @override
  void dispose() {
    super.dispose();
    controller.dispose();
    player.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Positioned.fill(
          child: Container(color: Colors.white),
        ),
        Align(
          alignment: Alignment.center,
          child: SizedBox(
            height: 300,
            width: 300,
            child: MobileScanner(
              controller: controller,
              onDetect: (BarcodeCapture capture)  {
                if (!widget.isBusyScanning) {
                    String? rawValue = capture.barcodes.isNotEmpty ? capture.barcodes[0].rawValue : null;
                    if (rawValue != null) {
                      List<String> splitValue = rawValue.split('_');
                      widget.onScanned(splitValue[1]);
                    }
                 }
              },
              errorBuilder: (context, error, child) {
                return errorWidget(context, error);
              },
            ),
          ),
        ),
      ],
    );
  }

  Widget errorWidget(BuildContext context, MobileScannerException? error) {
    String errorMessage;

    switch (error?.errorCode) {
      case MobileScannerErrorCode.controllerUninitialized:
        errorMessage = 'Controller not ready.';
      case MobileScannerErrorCode.permissionDenied:
        errorMessage = 'Permission denied';
      case MobileScannerErrorCode.unsupported:
        errorMessage = 'Scanning is unsupported on this device';
      default:
        errorMessage = 'Generic Error';
    }

    return ColoredBox(
      color: Colors.black,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const Padding(
              padding: EdgeInsets.only(bottom: 16),
              child: Icon(Icons.error, color: Colors.white),
            ),
            Text(
              errorMessage,
              style: const TextStyle(color: Colors.white),
            ),
            Text(
              error?.errorDetails?.message ?? '',
              style: const TextStyle(color: Colors.white),
            ),
          ],
        ),
      ),
    );
  }
}
Image

May be may someone let me know what will cause that error.

@yeewan98 yeewan98 changed the title ios 18.1 in chrome cannot show widget Chrome and safari in ios 18.1.1 cannot show widget Feb 6, 2025
@navaronbracke
Copy link
Collaborator

@navaronbracke
Copy link
Collaborator

Are you serving your app over https?

@yeewan98
Copy link
Author

yeewan98 commented Feb 10, 2025

Are you serving your app over https?

Yes.

Btw, thanks for providing some link for me to refer, after check with multiple device with same ios version, it seems like certain device have no this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants