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

Overlay example does not apply background opacity correctly #1185

Open
IanVS opened this issue Sep 20, 2024 · 3 comments
Open

Overlay example does not apply background opacity correctly #1185

IanVS opened this issue Sep 20, 2024 · 3 comments

Comments

@IanVS
Copy link
Contributor

IanVS commented Sep 20, 2024

I'm using the overlay example as a guide for building a feature in my app, and I noticed that the background opacity is not being applied outside of the scan window correctly:

Android Studio 2024-09-20 10 50 43

I'm a beginner flutter dev, so I don't know what might be causing this.

@navaronbracke
Copy link
Collaborator

This could be a bug in the example. Although, I think that the example just draws the white rectangle, and nothing else.

@IanVS
Copy link
Contributor Author

IanVS commented Sep 23, 2024

From what I can tell, it does try to apply some opacity.

https://github.com/juliansteenbakker/mobile_scanner/blob/c3271f0cda3df5594a4cebc02696007657785861/example/lib/mobile_scanner_overlay.dart#L147C21-L147C41

    // First, draw the background,
    // with a cutout area that is a bit larger than the scan window.
    // Finally, draw the scan window itself.
    canvas.drawPath(backgroundWithCutout, backgroundPaint);
    canvas.drawRRect(borderRect, borderPaint);

@RobertCer
Copy link

In ScannerOverlay example class, changing from:

final backgroundPaint = Paint()
  ..color = Colors.black.withOpacity(0.5)
  ..style = PaintingStyle.fill
  ..blendMode = BlendMode.dstOut;

to

final backgroundPaint = Paint()
  ..color = Colors.black.withOpacity(0.5)
  ..style = PaintingStyle.fill
  ..blendMode = BlendMode.srcOver; // <- This line

will add the background opacity.

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

3 participants