Skip to content

fix(package_info_plus): prefer compile-time build name and number on web - #3990

Open
Ortes wants to merge 2 commits into
fluttercommunity:mainfrom
Ortes:package-info-web-compile-time-version
Open

Ortes wants to merge 2 commits into
fluttercommunity:mainfrom
Ortes:package-info-web-compile-time-version

Conversation

@Ortes

@Ortes Ortes commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Description

On the web, version / buildNumber come from version.json, fetched from the server at runtime. It describes the currently deployed bundle, so a client running a stale cached bundle reports the newer version.

Since Flutter 3.47.0 (flutter/flutter#187935), flutter_tools injects the app's build name and number as the dart-defines FLUTTER_BUILD_NAME / FLUTTER_BUILD_NUMBER (exposed as appBuildName / appBuildNumber). They are compiled into the running bundle.

This PR makes the web implementation use them for version / buildNumber when defined:

  • read with bool.hasEnvironment, so the minimum Flutter version is unchanged; on older SDKs they're undefined and nothing changes;
  • appName / packageName still come from version.json;
  • the version stays correct even if the version.json fetch fails;
  • native platforms are untouched.

The web plugin constructor gains two optional positional parameters (build name / number) for tests, defaulting to the compiled values. The mocked web tests pass null so they keep covering the version.json path. Two new tests cover the compile-time path.

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing. (web integration tests not run locally; relying on CI)
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant