vintage / scratcher

Scratch card widget which temporarily hides content from user.
https://pub.dev/packages/scratcher
MIT License
572 stars 67 forks source link

The Scratch card doesn't get Scratched on mobile browsers #28

Closed parthgosalia closed 2 years ago

parthgosalia commented 3 years ago

It works perfectly fine in Chrome(PC) and also works great in mobile as app but it doesn't work in mobile browsers.

vintage commented 3 years ago

@parthgosalia

  1. What version of library are you using?
  2. What is the output of flutter doctor --verbose?
vintage commented 3 years ago

Closing due to inactivity.

harjotsingh1999 commented 3 years ago

version 2.1.0 Scratching doesn't function on mobile browsers

Here is the output of flutter -d verbose

 [√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19042.985], locale en-IN)
      • Flutter version 2.2.0 at H:\Flutter\flutter_dev\flutter
      • Framework revision b22742018b (2 weeks ago), 2021-05-14 19:12:57 -0700
      • Engine revision a9d88a4d18
      • Dart version 2.13.0

  [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
      • Android SDK at C:\Users\91970\AppData\Local\Android\sdk
      • Platform android-30, build-tools 29.0.3
      • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
      • All Android licenses accepted.

  [√] Chrome - develop for the web
      • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

  [√] Android Studio (version 4.0)
      • Android Studio at C:\Program Files\Android\Android Studio
      • Flutter plugin version 51.0.1
      • Dart plugin version 193.7547
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

  [√] VS Code (version 1.56.2)
      • VS Code at C:\Users\91970\AppData\Local\Programs\Microsoft VS Code
      • Flutter extension version 3.22.0

  [√] Connected device (2 available)
      • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
      • Edge (web)   • edge   • web-javascript • Microsoft Edge 91.0.864.37

  • No issues found! 

Worked perfectly on pc browsers though.

timcreatedit commented 3 years ago

I'm having this issue as well, attached output of flutter doctor -v

[✓] Flutter (Channel stable, 2.2.0, on macOS 11.4 20F71 darwin-arm, locale en-DE)
    • Flutter version 2.2.0 at /Users/tim/Library/flutter
    • Framework revision b22742018b (9 weeks ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/tim/Library/Android/sdk
    • Platform android-S, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode-Beta.app/Contents/Developer
    • Xcode 13.0, Build version 13A5155e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 58.0.3
    • Dart plugin version 211.7665

[✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 11.4 20F71 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 91.0.4472.114

• No issues found!
vmwsree commented 2 years ago

I am also having this problem. Is there any stable version that works on mobile browser

vintage commented 2 years ago

I would be more than happy to accept PR which solves the issue. Currently I cannot dedicate spare time to fix it on my end.

vmwsree commented 2 years ago

The issue seems to be on HTML renderer , According to https://flutter.dev/docs/development/tools/web-renderers

The --web-renderer command line option takes one of three values, auto, html, or canvaskit.
auto (default) - automatically chooses which renderer to use. This option chooses the HTML renderer when the app is running in a mobile browser, and CanvasKit renderer when the app is running in a desktop browser.

You have specify the build command as flutter build web --web-renderer canvaskit This will enable scratch feature in mobile browser. But If you still want HTML render I'm afraid We need a PR

souvik-bera commented 2 years ago

@vmwsree Thanks for your help on this issue. Yes using canvas kit fixes the scratch issue. But it's making the Text widgets bugged. It would be great if you provide any workaround. Here is mote details regarding it https://github.com/flutter/flutter/issues/74990

tcd93 commented 2 years ago

This library uses Paint(), and Paint doesn't work with html renderer, only Skia (pretty much all methods inside that class call Skia APIs)

I guess Flutter team should really do a better job at informing us that...

@vintage can you update README doc about html compatibility?

vintage commented 2 years ago

This library uses Paint(), and Paint doesn't work with html renderer, only Skia (pretty much all methods inside that class call Skia APIs)

I guess Flutter team should really do a better job at informing us that...

@vintage can you update README doc about html compatibility?

Thanks, didn't know the Paint doesn't work with web renderer! Updated readme with information that only CanvasKit is supported.

tcd93 commented 2 years ago

That was a bit of misinformation there about me assuming Flutter calls Skia API only in Paint class. Sorry.

What it did was calling native C methods inside bunch of dll files, I have no idea what it does behind the scene.

But if I change the Paint's blend mode to something like dst instead of src, then it'll throw Unimplemented error for Flutter Web, so I think they... forgot to put that message up for src blend mode, somehow?

Anyway this is out of our control now, gotta way until they actual fix this from their side.