website
                                
                                 website copied to clipboard
                                
                                    website copied to clipboard
                            
                            
                            
                        Explain differences and limitations for web apps
RE https://github.com/flutter/flutter/issues/106046#issuecomment-1172605241
We could take a lot of stuff from the FAQ page: https://docs.flutter.dev/development/platform-integration/web/faq
- concurrency (computefunction in the foundation lib)
- support for dart:io
- hot reload
- Platform.is...
etc
CC @johnpryan
I would prefer that we not include SEO in the list. SEO is not something that other Flutter platforms support, and it's not a fundamental limitation. It's something we just haven't seriously tackled yet.
From https://github.com/flutter/flutter/issues/106046#issuecomment-1172605241 (@ditman)
@Hamdor that's a great suggestion, we have a bunch of issues cut every so often that we can't fix because of how the web platform works (HTTP Responses not working because they're not CORS ready, Image.network, now the clipboard...)
I'll bring this up with the team to see if they have ideas on the best place to document all of this!
For security reasons, the Clipboard APIs are severely limited when working in a web browser. Here's some documentation:
- MDN - References > Web APIs > Clipboard > Clipboard availability
- Webkit - Async Clipboard API > See "Security and Privacy"
- Chrome - Web.dev > Unblocking clipboard access > Security and permissions
There's two things that I'm reading in the docs above that are affecting this issue:
- The
clipboard-writepermission is only granted to the currently active tab.- The request to write to the clipboard must be triggered during a user gesture.
- (Maybe) Your site needs to be on
https.Number 1 explains why "quickly switching tabs" breaks the ability to copy to the clipboard: your web app is losing the
clipboard-writepermission that is required by the browser.Number 2 explains the original issue. When a user gesture "takes too long" to happen, it ends up losing its "special" permissions (being considered a user activation event). This would be similar to attempting to open a URL after a delay, the popup blocker would block the opening of the window (even though it may have been triggered by a user gesture).
I think this article sums it up well, and has some extra info:
- https://textslashplain.com/2020/05/18/browser-basics-user-gestures
(Closing: this is a browser limitation. If you wrote equivalent code in vanilla JS, you'd have the same issue. There isn't much we can do from Flutter to help!)