Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@ditman
Copy link
Member

@ditman ditman commented Apr 25, 2024

This PR moves the core of browser_detection.dart to a location in dart:ui_web so it can be used by apps and plugins.

In order for the code to be a little bit tidier in ui_web, it's encapsulated in a singleton instance that can be accessed through BrowserDetection.instance or a top level global browser in dart:ui_web.

Issues

Tests

Updated affected tests. Mostly the update was to call the methods from web_ui.browser.methodName rather than a global scope. Also split the tests for this module in two files:

  • engine_browser_detect_test.dart - with the tests specific to the engine (capability detection, etc...)
  • browser_detect_test.dart - only the tests pertaining to the "core" of the library.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ditman ditman requested a review from mdebbar April 25, 2024 00:20
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Apr 25, 2024
@ditman ditman marked this pull request as ready for review April 25, 2024 01:31
ditman and others added 2 commits May 1, 2024 17:25
Updates documentation according to review comments.
@ditman ditman added the autosubmit Merge PR when tree becomes green via auto submit App label May 2, 2024
@auto-submit auto-submit bot merged commit b25f5d5 into flutter:main May 2, 2024
@ditman ditman deleted the expose-browser-detection branch May 2, 2024 01:46
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 2, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 2, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 7, 2024
> [!IMPORTANT]
> Requires the following engine PR:
> * flutter/engine#52380
> ----

This PR refactors Flutter `foundation`'s library `platform` for the web with the same code we use to detect platforms in the engine.

## Issues

* Fixes: #128943

## Testing

Demo app deployed here:

* https://dit-browser-detect.web.app
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme.of(context).platform running on web returns macOS instead of iOS when accessed from Safari on iPad

2 participants