Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dart-lang/core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: dart-lang/core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.2
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 48 files changed
  • 1 contributor

Commits on Apr 7, 2025

  1. New API with per-platform properties.

    The `Platform.current` object exposes one (or potentially more)
    of a `NativePlatform` (based on `dart:io`) or `BrowserPlatform`
    (based on JS `window.navigator` or anything else relevant).
    
    Each has its own API, and the current platform determines
    whether a value of these types is available or not.
    On unsupported platforms, a value is just `null`.
    
    Provides a `testing.dart` library which exposes
    `FakeNativePlatform` and `FakeBrowserPlatform`,
    which are customizable classes that can be used for testing.
    It's possible to run code with such a fake value as
    the *current* platform (`Platform.current` is temporarily
    updated to a value which exposes the, fx, `FakeNativePlatform`
    as its `Platform.nativePlatform`).
    
    Still retains the legacy and deprecated API that makes
    native properties directly available on `Platform`.
    Code should migrate to the new API by doing:
    * `const LocalPlatform()` → `Platform.current.nativePlatform!`
    * `new FakePlatform()` → `new FakeNativePlatform()`
    
    It's currently not possible to have more than one
    non-`null` platform-value.
    Platforms are detected by the presence of the `dart:io` and `dart:js_interop`
    libraries, and no current platform has both.
    When such a platform exists, the code will need to be adapted to to produce
    *both* (possible using conditional imports or conditional parts
    and augmentations).
    lrhn committed Apr 7, 2025
    Configuration menu
    Copy the full SHA
    7b89e44 View commit details
    Browse the repository at this point in the history
Loading