Skip to content

feat(web): native browser fullscreen via the Fullscreen API#946

Open
Ortes wants to merge 4 commits into
fluttercommunity:masterfrom
Ortes:feat/web-native-fullscreen
Open

feat(web): native browser fullscreen via the Fullscreen API#946
Ortes wants to merge 4 commits into
fluttercommunity:masterfrom
Ortes:feat/web-native-fullscreen

Conversation

@Ortes

@Ortes Ortes commented May 31, 2026

Copy link
Copy Markdown
Contributor

Problem

On Flutter Web, entering fullscreen only pushes a route that expands the Flutter view inside the browser window — it never enters the browser's real, OS-level fullscreen. Users expect the video to fill the whole screen (like every <video> element and every other web player), but instead it just fills the page. This is a long-standing rough edge for web users.

What this does

Adds an opt-out ChewieController.useNativeFullScreenOnWeb flag (default true) that, on web, also drives the browser's Fullscreen API:

  • Entering Chewie fullscreen calls document.documentElement.requestFullscreen() (issued before the first await, so it's still inside the user-gesture handler the browser requires).
  • Exiting Chewie fullscreen calls document.exitFullscreen().
  • Pressing Escape (which the browser handles itself) fires fullscreenchange; Chewie listens and exits its own fullscreen route so the two states stay in sync.

No behavior change on Android / iOS / desktop — the flag has no effect off web.

Implementation notes

  • Native fullscreen unavoidably needs JS interop. It's isolated behind a conditional import so non-web targets never reference package:web:
    • lib/src/web_fullscreen.dart — real impl (package:web + dart:js_interop)
    • lib/src/web_fullscreen_stub.dart — no-op stubs
  • lib/src/chewie_player.dart — new field + constructor arg + copyWith; listener registration in initState/dispose; enter/exit calls in _pushFullScreenWidget, all gated by the flag.
  • pubspec.yaml — adds web: ^1.0.0.

Happy to flip the default to false if you'd prefer it strictly opt-in, or to add a small example/integration test — let me know your preference.

Ortes and others added 2 commits May 31, 2026 08:25
When running as a Flutter Web app, the fullscreen button now triggers the
browser's native Fullscreen API (document.documentElement.requestFullscreen)
in addition to Chewie's internal route-based fullscreen. This gives users a
true OS-level fullscreen instead of just expanding within the browser window.

Pressing Escape to exit native fullscreen also collapses Chewie's fullscreen
route, keeping both states in sync.

Implemented via conditional import (dart.library.html): web_fullscreen.dart
uses package:web + dart:js_interop; web_fullscreen_stub.dart provides no-ops
for non-web platforms.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ChewieController.useNativeFullScreenOnWeb (default true) so the native
browser Fullscreen behavior is opt-out rather than an unconditional change.
No effect on non-web platforms. Also adds a CHANGELOG entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread lib/src/chewie_player.dart Outdated
Comment thread lib/src/chewie_player.dart Outdated
- Remove `// ignore: uri_does_not_exist`; chewie_player.dart now imports
  the plain `web_fullscreen.dart` abstraction, which conditionally
  exports the stub or the real implementation.
- Use `dart.library.js_interop` instead of `dart.library.html` for the
  conditional export.
- Move the dart:js_interop / package:web implementation into
  web_fullscreen_impl.dart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@diegotori

Copy link
Copy Markdown
Collaborator

There are conflicts to resolve before this can be merged. Thanks.

…ullscreen

# Conflicts:
#	CHANGELOG.md
#	pubspec.yaml
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.79%. Comparing base (69a8fc7) to head (115e7cb).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/chewie_player.dart 41.66% 7 Missing ⚠️
lib/src/web_fullscreen_stub.dart 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #946      +/-   ##
==========================================
- Coverage   43.82%   43.79%   -0.03%     
==========================================
  Files          21       22       +1     
  Lines        1602     1619      +17     
==========================================
+ Hits          702      709       +7     
- Misses        900      910      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

2 participants