Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[package_info_plus]: Use Flutter's compile-time build name/number on web instead of version.json

未关闭
#3,989 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Ortes 已经在做这个了。

开始于 2026年9月29日。

  • #3990 来自 @Ortes —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
dart, flutter
领域
web-dev

调研方向

Start in the package_info_plus web implementation and review its current version.json loading path. Verify the compile-time build values are preferred when available, version.json remains the fallback, and native behavior is unchanged; the linked PR #3990 indicates work is already underway.

由索引模型根据 Issue 内容生成。

描述

Plugin

package_info_plus

Use case

On the web, PackageInfo.fromPlatform() reads version / buildNumber from version.json, fetched from the server at runtime. That file describes the currently deployed bundle, not the one running. A client on a stale cached bundle therefore reports the new version, so update gates and "running version" displays fail for exactly the users they exist for (#2675, closed as not planned). The fetch can also fail outright (#456, #3028).

Since Flutter 3.47.0 (flutter/flutter#187935), flutter_tools injects the app's pubspec version (or --build-name / --build-number) as the dart-defines FLUTTER_BUILD_NAME / FLUTTER_BUILD_NUMBER, exposed as appBuildName / appBuildNumber in package:flutter/services.dart. They are compiled into the bundle, so they always describe the code that is executing.

Proposal

In the web implementation, prefer the compile-time values when present and keep version.json as the fallback:

const _buildName = bool.hasEnvironment('FLUTTER_BUILD_NAME')
    ? String.fromEnvironment('FLUTTER_BUILD_NAME')
    : null;
const _buildNumber = bool.hasEnvironment('FLUTTER_BUILD_NUMBER')
    ? String.fromEnvironment('FLUTTER_BUILD_NUMBER')
    : null;

Reading the defines through bool.hasEnvironment (instead of importing appBuildName) keeps the current minimum Flutter version: older SDKs just don't define them, and behaviour is unchanged. On native platforms nothing changes.

This fixes #2675 transparently for every consumer, including SDKs that derive their release from package_info_plus (for example sentry_flutter's release name).

PR: #3990 (replaces the opt-in approach of #3874, which I closed once the Flutter side landed).

主要语言
Dart
星标
1.9k
派生
1.3k
平均合并
4 天 2 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fluttercommunity/plus_plugins 的其他 Issue

查看 fluttercommunity/plus_plugins 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。